[Swift Export] KT-65008: support simple top-level properties

Merge-request: KT-MR-14131
Merged-by: Gleb Lukianets <Gleb.Lukianets@jetbrains.com>
This commit is contained in:
Gleb Lukianets
2024-02-05 16:29:37 +00:00
committed by Space Team
parent ad5ee28d58
commit f262247b2b
49 changed files with 1172 additions and 72 deletions
@@ -22,5 +22,9 @@ class BuilderConfigurator(elements: List<Element>) : AbstractSwiftIrTreeBuilderC
configureFieldInAllLeafBuilders("visibility") {
default(it, "SirVisibility.PUBLIC")
}
builder(setter) {
default("parameterName", "\"newValue\"")
}
}
}
@@ -78,9 +78,15 @@ object SwiftIrTree : AbstractSwiftIrTreeBuilder() {
parent(declaration)
}
// Denotes "actual" callable node. (I.e. SirCallable & !SIRForeignDeclaration)
// TODO: remove along with foreign declaration (KT-65335); replace usages with just SIRCallable
val nativeCallable by sealedElement {
parent(callable)
}
val function by element {
customParentInVisitor = callable
parent(callable)
parent(nativeCallable)
+field("isStatic", boolean) // todo: KT-65046 Method|function distinction in SIR
+field("name", string)
@@ -98,4 +104,42 @@ object SwiftIrTree : AbstractSwiftIrTreeBuilder() {
visitorParameterName = "function"
}
val accessor by sealedElement {
customParentInVisitor = callable
parent(nativeCallable)
+field("body", functionBodyType, nullable = true, mutable = true)
}
val getter by element {
parent(accessor)
}
val setter by element {
parent(accessor)
+field("parameterName", string, initializer = { })
}
val variable by element {
customParentInVisitor = declaration
parent(declaration)
parent(declarationParent)
+field("name", string)
+field("type", typeType)
+field("getter", getter)
+field("setter", setter, nullable = true)
+field("isStatic", boolean) // todo: KT-65046 Method|function distinction in SIR
}
val foreignVariable by element {
customParentInVisitor = declaration
parent(foreignDeclaration)
visitorParameterName = "variable"
}
}