IrSyntheticBody (for 'values', 'valueOf').
This commit is contained in:
committed by
Dmitry Petrov
parent
c47e82f965
commit
2d2100b1b5
@@ -44,6 +44,7 @@ enum class IrDeclarationKind {
|
||||
enum class IrDeclarationOrigin {
|
||||
DEFINED,
|
||||
CLASS_FOR_ENUM_ENTRY,
|
||||
ENUM_CLASS_SPECIAL_MEMBER,
|
||||
GENERATED_DATA_CLASS_MEMBER,
|
||||
LOCAL_FUNCTION_FOR_LAMBDA,
|
||||
IR_TEMPORARY_VARIABLE,
|
||||
|
||||
@@ -30,6 +30,15 @@ interface IrBlockBody : IrBody {
|
||||
val statements: List<IrStatement>
|
||||
}
|
||||
|
||||
interface IrSyntheticBody : IrBody {
|
||||
val kind: IrSyntheticBodyKind
|
||||
}
|
||||
|
||||
enum class IrSyntheticBodyKind {
|
||||
ENUM_VALUES,
|
||||
ENUM_VALUEOF
|
||||
}
|
||||
|
||||
class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrExpressionBody {
|
||||
constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) {
|
||||
this.expression = expression
|
||||
@@ -93,6 +102,20 @@ class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOff
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
statements.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
}
|
||||
|
||||
class IrSyntheticBodyImpl(startOffset: Int, endOffset: Int, override val kind: IrSyntheticBodyKind) : IrElementBase(startOffset, endOffset), IrSyntheticBody {
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||
return visitor.visitSyntheticBody(this, data)
|
||||
}
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
// no children
|
||||
}
|
||||
|
||||
override fun getChild(slot: Int): IrElement? = null
|
||||
|
||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||
throwNoSuchSlot(slot)
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,9 @@ class RenderIrElementVisitor : IrElementVisitor<String, Nothing?> {
|
||||
override fun visitBlockBody(body: IrBlockBody, data: Nothing?): String =
|
||||
"BLOCK_BODY"
|
||||
|
||||
override fun visitSyntheticBody(body: IrSyntheticBody, data: Nothing?): String =
|
||||
"SYNTHETIC_BODY kind=${body.kind}"
|
||||
|
||||
override fun visitExpression(expression: IrExpression, data: Nothing?): String =
|
||||
"? ${expression.javaClass.simpleName} type=${expression.type.render()}"
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ interface IrElementVisitor<out R, in D> {
|
||||
fun visitBody(body: IrBody, data: D): R = visitElement(body, data)
|
||||
fun visitExpressionBody(body: IrExpressionBody, data: D): R = visitBody(body, data)
|
||||
fun visitBlockBody(body: IrBlockBody, data: D) = visitBody(body, data)
|
||||
fun visitSyntheticBody(body: IrSyntheticBody, data: D) = visitBody(body, data)
|
||||
|
||||
fun visitExpression(expression: IrExpression, data: D): R = visitElement(expression, data)
|
||||
fun <T> visitConst(expression: IrConst<T>, data: D): R = visitExpression(expression, data)
|
||||
|
||||
Reference in New Issue
Block a user