rrn/rd/KT-63266/sir-gen
Swift Export: generated sir snapshot Merge-request: KT-MR-13128 Merged-by: Gleb Lukianets <Gleb.Lukianets@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
1f4099833a
commit
c3725ec8c8
+9
-1
@@ -11,8 +11,12 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.psi.KtTreeVisitorVoid
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isPublic
|
||||
import org.jetbrains.kotlin.sir.SirOrigin
|
||||
import org.jetbrains.kotlin.sir.SirDeclaration
|
||||
import org.jetbrains.kotlin.sir.SirForeignFunction
|
||||
import org.jetbrains.kotlin.sir.SirVisibility
|
||||
import org.jetbrains.kotlin.sir.builder.SirForeignFunctionBuilder
|
||||
import org.jetbrains.kotlin.sir.builder.buildForeignFunction
|
||||
|
||||
/**
|
||||
* A root interface for classes that produce Swift IR elements.
|
||||
@@ -36,7 +40,11 @@ class SirGenerator : SirFactory {
|
||||
?.fqName
|
||||
?.pathSegments()
|
||||
?.toListString()
|
||||
?.let { names -> SirForeignFunction(fqName = names) }
|
||||
?.let { names -> buildForeignFunction {
|
||||
origin = SirOrigin(path = names)
|
||||
visibility = SirVisibility.PUBLIC
|
||||
}
|
||||
}
|
||||
?.let { res.add(it) }
|
||||
}
|
||||
}
|
||||
|
||||
+11
-6
@@ -12,8 +12,11 @@ import org.jetbrains.kotlin.analysis.test.framework.test.configurators.*
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.FrontendKind
|
||||
import org.jetbrains.kotlin.platform.konan.NativePlatforms
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.sir.SirDeclaration
|
||||
import org.jetbrains.kotlin.sir.SirForeignFunction
|
||||
import org.jetbrains.kotlin.sir.SirModule
|
||||
import org.jetbrains.kotlin.sir.builder.SirModuleBuilder
|
||||
import org.jetbrains.kotlin.sir.builder.buildModule
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
@@ -46,16 +49,18 @@ abstract class AbstractKotlinSirContextTestBase : AbstractAnalysisApiBasedTest()
|
||||
val ktFiles = moduleStructure.modules
|
||||
.flatMap { testServices.ktModuleProvider.getModuleFiles(it).filterIsInstance<KtFile>() }
|
||||
|
||||
val module = SirModule()
|
||||
val sirFactory = SirGenerator()
|
||||
ktFiles.forEach { file ->
|
||||
module.declarations += sirFactory.build(file)
|
||||
}
|
||||
val module = buildModule() {
|
||||
val sirFactory = SirGenerator()
|
||||
ktFiles.forEach { file ->
|
||||
declarations += sirFactory.build(file)
|
||||
}
|
||||
}.build()
|
||||
|
||||
val actual = buildString {
|
||||
module.declarations
|
||||
.filterIsInstance<SirForeignFunction>()
|
||||
.forEach {
|
||||
appendLine("${it.fqName}")
|
||||
appendLine("${it.origin.path}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,17 @@ description = "Swift Intermediate Representation"
|
||||
dependencies {
|
||||
compileOnly(kotlinStdlib())
|
||||
|
||||
testImplementation(libs.junit4)
|
||||
testApi(platform(libs.junit.bom))
|
||||
testImplementation(libs.junit.jupiter.api)
|
||||
testRuntimeOnly(libs.junit.jupiter.engine)
|
||||
|
||||
testImplementation(projectTests(":compiler:tests-common"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"main" {
|
||||
projectDefault()
|
||||
generatedDir()
|
||||
}
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.callable]
|
||||
*/
|
||||
sealed interface SirCallable : SirDeclaration {
|
||||
override val origin: SirOrigin
|
||||
override val visibility: SirVisibility
|
||||
override var parent: SirDeclarationParent
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitCallable(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformCallable(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.declaration]
|
||||
*/
|
||||
sealed interface SirDeclaration : SirElement {
|
||||
val origin: SirOrigin
|
||||
val visibility: SirVisibility
|
||||
var parent: SirDeclarationParent
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitDeclaration(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformDeclaration(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.declarationContainer]
|
||||
*/
|
||||
sealed class SirDeclarationContainer : SirDeclarationParent() {
|
||||
abstract val declarations: List<SirDeclaration>
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitDeclarationContainer(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformDeclarationContainer(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.declarationParent]
|
||||
*/
|
||||
sealed class SirDeclarationParent : SirElementBase(), SirElement
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.declarationWithName]
|
||||
*/
|
||||
sealed interface SirDeclarationWithName : SirDeclaration {
|
||||
override val origin: SirOrigin
|
||||
override val visibility: SirVisibility
|
||||
override var parent: SirDeclarationParent
|
||||
val name: String
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitDeclarationWithName(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformDeclarationWithName(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* The root interface of the Swift IR tree.
|
||||
*
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.rootElement]
|
||||
*/
|
||||
sealed interface SirElement {
|
||||
/**
|
||||
* Runs the provided [visitor] on the Swift IR subtree with the root at this node.
|
||||
*
|
||||
* @param visitor The visitor to accept.
|
||||
* @param data An arbitrary context to pass to each invocation of [visitor]'s methods.
|
||||
* @return The value returned by the topmost `visit*` invocation.
|
||||
*/
|
||||
fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R
|
||||
|
||||
/**
|
||||
* Runs the provided [transformer] on the Swift IR subtree with the root at this node.
|
||||
*
|
||||
* @param transformer The transformer to use.
|
||||
* @param data An arbitrary context to pass to each invocation of [transformer]'s methods.
|
||||
* @return The transformed node.
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformElement(this, data) as E
|
||||
|
||||
/**
|
||||
* Runs the provided [visitor] on subtrees with roots in this node's children.
|
||||
*
|
||||
* Basically, calls `accept(visitor, data)` on each child of this node.
|
||||
*
|
||||
* Does **not** run [visitor] on this node itself.
|
||||
*
|
||||
* @param visitor The visitor for children to accept.
|
||||
* @param data An arbitrary context to pass to each invocation of [visitor]'s methods.
|
||||
*/
|
||||
fun <R, D> acceptChildren(visitor: SirVisitor<R, D>, data: D)
|
||||
|
||||
/**
|
||||
* Recursively transforms this node's children *in place* using [transformer].
|
||||
*
|
||||
* Basically, executes `this.child = this.child.transform(transformer, data)` for each child of this node.
|
||||
*
|
||||
* Does **not** run [transformer] on this node itself.
|
||||
*
|
||||
* @param transformer The transformer to use for transforming the children.
|
||||
* @param data An arbitrary context to pass to each invocation of [transformer]'s methods.
|
||||
*/
|
||||
fun <D> transformChildren(transformer: SirTransformer<D>, data: D)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.enum]
|
||||
*/
|
||||
abstract class SirEnum : SirDeclarationContainer(), SirNamedTypeDeclaration {
|
||||
abstract override val origin: SirOrigin
|
||||
abstract override val visibility: SirVisibility
|
||||
abstract override var parent: SirDeclarationParent
|
||||
abstract override val name: String
|
||||
abstract override val declarations: List<SirDeclaration>
|
||||
abstract val cases: List<SirEnumCase>
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitEnum(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformEnum(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.foreignDeclaration]
|
||||
*/
|
||||
sealed class SirForeignDeclaration : SirElementBase(), SirDeclaration {
|
||||
abstract override val origin: SirOrigin
|
||||
abstract override val visibility: SirVisibility
|
||||
abstract override var parent: SirDeclarationParent
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitForeignDeclaration(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformForeignDeclaration(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.foreignFunction]
|
||||
*/
|
||||
abstract class SirForeignFunction : SirForeignDeclaration(), SirCallable {
|
||||
abstract override val origin: SirOrigin
|
||||
abstract override val visibility: SirVisibility
|
||||
abstract override var parent: SirDeclarationParent
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitForeignFunction(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformForeignFunction(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.function]
|
||||
*/
|
||||
abstract class SirFunction : SirElementBase(), SirCallable {
|
||||
abstract override val origin: SirOrigin
|
||||
abstract override val visibility: SirVisibility
|
||||
abstract override var parent: SirDeclarationParent
|
||||
abstract val name: String
|
||||
abstract val parameters: List<SirParameter>
|
||||
abstract val returnType: SirType
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitFunction(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformFunction(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.module]
|
||||
*/
|
||||
abstract class SirModule : SirDeclarationContainer() {
|
||||
abstract override val declarations: List<SirDeclaration>
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitModule(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformModule(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
/**
|
||||
* Generated from: [org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree.namedTypeDeclaration]
|
||||
*/
|
||||
sealed interface SirNamedTypeDeclaration : SirDeclarationWithName {
|
||||
override val origin: SirOrigin
|
||||
override val visibility: SirVisibility
|
||||
override var parent: SirDeclarationParent
|
||||
override val name: String
|
||||
|
||||
override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R =
|
||||
visitor.visitNamedTypeDeclaration(this, data)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E =
|
||||
transformer.transformNamedTypeDeclaration(this, data) as E
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
@file:Suppress("DuplicatedCode", "unused")
|
||||
|
||||
package org.jetbrains.kotlin.sir.builder
|
||||
|
||||
import kotlin.contracts.*
|
||||
import org.jetbrains.kotlin.sir.*
|
||||
import org.jetbrains.kotlin.sir.impl.SirEnumImpl
|
||||
|
||||
@SirBuilderDsl
|
||||
class SirEnumBuilder {
|
||||
lateinit var origin: SirOrigin
|
||||
lateinit var visibility: SirVisibility
|
||||
lateinit var name: String
|
||||
val declarations: MutableList<SirDeclaration> = mutableListOf()
|
||||
val cases: MutableList<SirEnumCase> = mutableListOf()
|
||||
|
||||
fun build(): SirEnum {
|
||||
return SirEnumImpl(
|
||||
origin,
|
||||
visibility,
|
||||
name,
|
||||
declarations,
|
||||
cases,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun buildEnum(init: SirEnumBuilder.() -> Unit): SirEnum {
|
||||
contract {
|
||||
callsInPlace(init, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return SirEnumBuilder().apply(init).build()
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
@file:Suppress("DuplicatedCode", "unused")
|
||||
|
||||
package org.jetbrains.kotlin.sir.builder
|
||||
|
||||
import kotlin.contracts.*
|
||||
import org.jetbrains.kotlin.sir.SirOrigin
|
||||
import org.jetbrains.kotlin.sir.SirBuilderDsl
|
||||
import org.jetbrains.kotlin.sir.SirForeignFunction
|
||||
import org.jetbrains.kotlin.sir.SirVisibility
|
||||
import org.jetbrains.kotlin.sir.impl.SirForeignFunctionImpl
|
||||
|
||||
@SirBuilderDsl
|
||||
class SirForeignFunctionBuilder {
|
||||
lateinit var origin: SirOrigin
|
||||
lateinit var visibility: SirVisibility
|
||||
|
||||
fun build(): SirForeignFunction {
|
||||
return SirForeignFunctionImpl(
|
||||
origin,
|
||||
visibility,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun buildForeignFunction(init: SirForeignFunctionBuilder.() -> Unit): SirForeignFunction {
|
||||
contract {
|
||||
callsInPlace(init, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return SirForeignFunctionBuilder().apply(init).build()
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
@file:Suppress("DuplicatedCode", "unused")
|
||||
|
||||
package org.jetbrains.kotlin.sir.builder
|
||||
|
||||
import kotlin.contracts.*
|
||||
import org.jetbrains.kotlin.sir.*
|
||||
import org.jetbrains.kotlin.sir.impl.SirFunctionImpl
|
||||
|
||||
@SirBuilderDsl
|
||||
class SirFunctionBuilder {
|
||||
lateinit var origin: SirOrigin
|
||||
lateinit var visibility: SirVisibility
|
||||
lateinit var name: String
|
||||
val parameters: MutableList<SirParameter> = mutableListOf()
|
||||
lateinit var returnType: SirType
|
||||
|
||||
fun build(): SirFunction {
|
||||
return SirFunctionImpl(
|
||||
origin,
|
||||
visibility,
|
||||
name,
|
||||
parameters,
|
||||
returnType,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun buildFunction(init: SirFunctionBuilder.() -> Unit): SirFunction {
|
||||
contract {
|
||||
callsInPlace(init, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return SirFunctionBuilder().apply(init).build()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
@file:Suppress("DuplicatedCode", "unused")
|
||||
|
||||
package org.jetbrains.kotlin.sir.builder
|
||||
|
||||
import kotlin.contracts.*
|
||||
import org.jetbrains.kotlin.sir.SirBuilderDsl
|
||||
import org.jetbrains.kotlin.sir.SirDeclaration
|
||||
import org.jetbrains.kotlin.sir.SirModule
|
||||
import org.jetbrains.kotlin.sir.impl.SirModuleImpl
|
||||
|
||||
@SirBuilderDsl
|
||||
class SirModuleBuilder {
|
||||
val declarations: MutableList<SirDeclaration> = mutableListOf()
|
||||
|
||||
fun build(): SirModule {
|
||||
return SirModuleImpl(
|
||||
declarations,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
inline fun buildModule(init: SirModuleBuilder.() -> Unit = {}): SirModule {
|
||||
contract {
|
||||
callsInPlace(init, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return SirModuleBuilder().apply(init).build()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir.impl
|
||||
|
||||
import org.jetbrains.kotlin.sir.*
|
||||
import org.jetbrains.kotlin.sir.util.transformInPlace
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
internal class SirEnumImpl(
|
||||
override val origin: SirOrigin,
|
||||
override val visibility: SirVisibility,
|
||||
override val name: String,
|
||||
override val declarations: MutableList<SirDeclaration>,
|
||||
override val cases: MutableList<SirEnumCase>,
|
||||
) : SirEnum() {
|
||||
override lateinit var parent: SirDeclarationParent
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: SirVisitor<R, D>, data: D) {
|
||||
declarations.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: SirTransformer<D>, data: D) {
|
||||
declarations.transformInPlace(transformer, data)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir.impl
|
||||
|
||||
import org.jetbrains.kotlin.sir.SirOrigin
|
||||
import org.jetbrains.kotlin.sir.SirDeclarationParent
|
||||
import org.jetbrains.kotlin.sir.SirForeignFunction
|
||||
import org.jetbrains.kotlin.sir.SirVisibility
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
internal class SirForeignFunctionImpl(
|
||||
override val origin: SirOrigin,
|
||||
override val visibility: SirVisibility,
|
||||
) : SirForeignFunction() {
|
||||
override lateinit var parent: SirDeclarationParent
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: SirVisitor<R, D>, data: D) {
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: SirTransformer<D>, data: D) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir.impl
|
||||
|
||||
import org.jetbrains.kotlin.sir.*
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
internal class SirFunctionImpl(
|
||||
override val origin: SirOrigin,
|
||||
override val visibility: SirVisibility,
|
||||
override val name: String,
|
||||
override val parameters: MutableList<SirParameter>,
|
||||
override val returnType: SirType,
|
||||
) : SirFunction() {
|
||||
override lateinit var parent: SirDeclarationParent
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: SirVisitor<R, D>, data: D) {
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: SirTransformer<D>, data: D) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir.impl
|
||||
|
||||
import org.jetbrains.kotlin.sir.SirDeclaration
|
||||
import org.jetbrains.kotlin.sir.SirModule
|
||||
import org.jetbrains.kotlin.sir.util.transformInPlace
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
|
||||
internal class SirModuleImpl(
|
||||
override val declarations: MutableList<SirDeclaration>,
|
||||
) : SirModule() {
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: SirVisitor<R, D>, data: D) {
|
||||
declarations.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: SirTransformer<D>, data: D) {
|
||||
declarations.transformInPlace(transformer, data)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir.visitors
|
||||
|
||||
import org.jetbrains.kotlin.sir.*
|
||||
|
||||
/**
|
||||
* Auto-generated by [org.jetbrains.kotlin.sir.tree.generator.printer.TransformerPrinter]
|
||||
*/
|
||||
abstract class SirTransformer<in D> : SirVisitor<SirElement, D>() {
|
||||
|
||||
abstract fun <E : SirElement> transformElement(element: E, data: D): E
|
||||
|
||||
final override fun visitElement(element: SirElement, data: D): SirElement {
|
||||
return transformElement(element, data)
|
||||
}
|
||||
|
||||
open fun transformModule(module: SirModule, data: D): SirModule {
|
||||
return transformElement(module, data)
|
||||
}
|
||||
|
||||
final override fun visitModule(module: SirModule, data: D): SirModule {
|
||||
return transformModule(module, data)
|
||||
}
|
||||
|
||||
|
||||
open fun transformDeclarationContainer(declarationContainer: SirDeclarationContainer, data: D): SirDeclarationContainer {
|
||||
return transformElement(declarationContainer, data)
|
||||
}
|
||||
|
||||
final override fun visitDeclarationContainer(declarationContainer: SirDeclarationContainer, data: D): SirDeclarationContainer {
|
||||
return transformDeclarationContainer(declarationContainer, data)
|
||||
}
|
||||
|
||||
open fun transformDeclaration(declaration: SirDeclaration, data: D): SirDeclaration {
|
||||
return transformElement(declaration, data)
|
||||
}
|
||||
|
||||
final override fun visitDeclaration(declaration: SirDeclaration, data: D): SirDeclaration {
|
||||
return transformDeclaration(declaration, data)
|
||||
}
|
||||
|
||||
open fun transformForeignDeclaration(foreignDeclaration: SirForeignDeclaration, data: D): SirDeclaration {
|
||||
return transformElement(foreignDeclaration, data)
|
||||
}
|
||||
|
||||
final override fun visitForeignDeclaration(foreignDeclaration: SirForeignDeclaration, data: D): SirDeclaration {
|
||||
return transformForeignDeclaration(foreignDeclaration, data)
|
||||
}
|
||||
|
||||
open fun transformDeclarationWithName(declarationWithName: SirDeclarationWithName, data: D): SirDeclaration {
|
||||
return transformElement(declarationWithName, data)
|
||||
}
|
||||
|
||||
final override fun visitDeclarationWithName(declarationWithName: SirDeclarationWithName, data: D): SirDeclaration {
|
||||
return transformDeclarationWithName(declarationWithName, data)
|
||||
}
|
||||
|
||||
open fun transformNamedTypeDeclaration(namedTypeDeclaration: SirNamedTypeDeclaration, data: D): SirDeclaration {
|
||||
return transformElement(namedTypeDeclaration, data)
|
||||
}
|
||||
|
||||
final override fun visitNamedTypeDeclaration(namedTypeDeclaration: SirNamedTypeDeclaration, data: D): SirDeclaration {
|
||||
return transformNamedTypeDeclaration(namedTypeDeclaration, data)
|
||||
}
|
||||
|
||||
open fun transformEnum(enum: SirEnum, data: D): SirDeclaration {
|
||||
return transformElement(enum, data)
|
||||
}
|
||||
|
||||
final override fun visitEnum(enum: SirEnum, data: D): SirDeclaration {
|
||||
return transformEnum(enum, data)
|
||||
}
|
||||
|
||||
open fun transformCallable(callable: SirCallable, data: D): SirDeclaration {
|
||||
return transformElement(callable, data)
|
||||
}
|
||||
|
||||
final override fun visitCallable(callable: SirCallable, data: D): SirDeclaration {
|
||||
return transformCallable(callable, data)
|
||||
}
|
||||
|
||||
open fun transformFunction(function: SirFunction, data: D): SirDeclaration {
|
||||
return transformElement(function, data)
|
||||
}
|
||||
|
||||
final override fun visitFunction(function: SirFunction, data: D): SirDeclaration {
|
||||
return transformFunction(function, data)
|
||||
}
|
||||
|
||||
open fun transformForeignFunction(foreignFunction: SirForeignFunction, data: D): SirDeclaration {
|
||||
return transformElement(foreignFunction, data)
|
||||
}
|
||||
|
||||
final override fun visitForeignFunction(foreignFunction: SirForeignFunction, data: D): SirDeclaration {
|
||||
return transformForeignFunction(foreignFunction, data)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||
// DO NOT MODIFY IT MANUALLY.
|
||||
|
||||
package org.jetbrains.kotlin.sir.visitors
|
||||
|
||||
import org.jetbrains.kotlin.sir.*
|
||||
|
||||
/**
|
||||
* Auto-generated by [org.jetbrains.kotlin.sir.tree.generator.printer.VisitorPrinter]
|
||||
*/
|
||||
abstract class SirVisitor<out R, in D> {
|
||||
|
||||
abstract fun visitElement(element: SirElement, data: D): R
|
||||
|
||||
open fun visitModule(module: SirModule, data: D): R =
|
||||
visitElement(module, data)
|
||||
|
||||
open fun visitDeclarationContainer(declarationContainer: SirDeclarationContainer, data: D): R =
|
||||
visitElement(declarationContainer, data)
|
||||
|
||||
open fun visitDeclaration(declaration: SirDeclaration, data: D): R =
|
||||
visitElement(declaration, data)
|
||||
|
||||
open fun visitForeignDeclaration(foreignDeclaration: SirForeignDeclaration, data: D): R =
|
||||
visitDeclaration(foreignDeclaration, data)
|
||||
|
||||
open fun visitDeclarationWithName(declarationWithName: SirDeclarationWithName, data: D): R =
|
||||
visitDeclaration(declarationWithName, data)
|
||||
|
||||
open fun visitNamedTypeDeclaration(namedTypeDeclaration: SirNamedTypeDeclaration, data: D): R =
|
||||
visitDeclarationWithName(namedTypeDeclaration, data)
|
||||
|
||||
open fun visitEnum(enum: SirEnum, data: D): R =
|
||||
visitNamedTypeDeclaration(enum, data)
|
||||
|
||||
open fun visitCallable(callable: SirCallable, data: D): R =
|
||||
visitDeclaration(callable, data)
|
||||
|
||||
open fun visitFunction(function: SirFunction, data: D): R =
|
||||
visitCallable(function, data)
|
||||
|
||||
open fun visitForeignFunction(foreignFunction: SirForeignFunction, data: D): R =
|
||||
visitCallable(foreignFunction, data)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
@DslMarker
|
||||
annotation class SirBuilderDsl
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
/**
|
||||
* A marker interface that denotes Swift IR elements.
|
||||
*/
|
||||
interface SirElement {
|
||||
}
|
||||
|
||||
class SirModule : SirElement {
|
||||
val declarations: MutableList<SirDeclaration> =
|
||||
mutableListOf()
|
||||
}
|
||||
|
||||
interface SirDeclaration
|
||||
|
||||
class SirForeignFunction(val fqName: List<String>) : SirDeclaration
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
|
||||
sealed class SirElementBase : SirElement {
|
||||
abstract override fun <R, D> accept(visitor: SirVisitor<R, D>, data: D): R
|
||||
|
||||
abstract override fun <E : SirElement, D> transform(transformer: SirTransformer<D>, data: D): E
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
class SirEnumCase(
|
||||
val name: String,
|
||||
val parameters: List<SirParameter>
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
@Suppress("unused")
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||
annotation class SirImplementationDetail
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
data class SirOrigin(val path: List<String>)
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
data class SirParameter(
|
||||
val argumentName: String? = null, // external function parameter (argument) name
|
||||
val parameterName: String? = null, // internal function parameter name
|
||||
val type: SirType,
|
||||
/* TODO: val defaultValue: Expression? = null, */
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
sealed interface SirType
|
||||
|
||||
class SirNominalType(
|
||||
val type: SirNamedTypeDeclaration,
|
||||
val parent: SirNominalType? = null,
|
||||
) : SirType
|
||||
|
||||
class SirExistentialType(
|
||||
// TODO: Protocols. For now, only `any Any` is supported
|
||||
) : SirType
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
enum class SirVisibility {
|
||||
PRIVATE,
|
||||
FILEPRIVATE,
|
||||
INTERNAL,
|
||||
PUBLIC,
|
||||
PACKAGE,
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.sir.util
|
||||
|
||||
import org.jetbrains.kotlin.sir.SirElement
|
||||
import org.jetbrains.kotlin.sir.SirElementBase
|
||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||
|
||||
// FIXME: Copy-pasted from FIR, use auto-generation instead.
|
||||
fun <T : SirElement, D> MutableList<T>.transformInPlace(transformer: SirTransformer<D>, data: D) {
|
||||
val iterator = this.listIterator()
|
||||
while (iterator.hasNext()) {
|
||||
val next = iterator.next() as SirElementBase
|
||||
val result = next.transform<T, D>(transformer, data)
|
||||
if (result !== next) {
|
||||
iterator.set(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.sir
|
||||
|
||||
import org.jetbrains.kotlin.sir.builder.SirEnumBuilder
|
||||
import org.jetbrains.kotlin.sir.builder.buildEnum
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@@ -14,10 +16,16 @@ class SirTest {
|
||||
@Test
|
||||
fun exampleTest() {
|
||||
val fakeElement = produceSwiftElement()
|
||||
|
||||
println(fakeElement)
|
||||
assertTrue(fakeElement is SirElement)
|
||||
}
|
||||
|
||||
private fun produceSwiftElement(): Any {
|
||||
return object : SirElement {}
|
||||
return buildEnum {
|
||||
origin = SirOrigin(path = listOf())
|
||||
name = "name"
|
||||
visibility = SirVisibility.PUBLIC
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user