[Swift Export] initial infrastructure for Swift IR

New modules 'sir', 'sir-passes', and 'sir-analysis-api' were added under
'native:swift' for creating and manipulating Swift IR elements.

* `sir` contains the implementation of Swift IR.
* `sir-analysis-api` contains translation from Analysis API to SIR.
* `sir-passses` contains transformation passes.

This groundwork will allow to progress with the Swift IR.
This commit is contained in:
Sergey Bogolepov
2023-11-08 15:43:43 +02:00
committed by Space Team
parent d15ee71b6c
commit cc14f11e2a
10 changed files with 193 additions and 0 deletions
@@ -0,0 +1,20 @@
plugins {
kotlin("jvm")
}
description = "Build Swift IR from Analysis"
dependencies {
compileOnly(kotlinStdlib())
api(project(":native:swift:sir"))
api(project(":analysis:analysis-api"))
testImplementation(libs.junit4)
testImplementation(projectTests(":compiler:tests-common"))
}
sourceSets {
"main" { projectDefault() }
"test" { projectDefault() }
}
@@ -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.analysisapi
import org.jetbrains.kotlin.sir.SirElement
/**
* A root interface for classes that produce Swift IR elements.
*/
interface SirFactory {
fun build(): SirElement
}
@@ -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.
*/
package org.jetbrains.kotlin.sir.analysisapi
import org.jetbrains.kotlin.sir.SirElement
import org.junit.Test
import kotlin.test.assertEquals
class FactoryTests {
@Test
fun smoke() {
val expectedString = "Element from factory"
val myFactory = object : SirFactory {
override fun build(): SirElement {
return object : SirElement {
override fun toString(): String {
return expectedString
}
}
}
}
val element = myFactory.build()
assertEquals(expectedString, element.toString())
}
}