IrContinue support in IR serializer.
This commit is contained in:
committed by
alexander-gorshenev
parent
5b66a62da5
commit
b763e003ae
+21
-15
@@ -112,6 +112,11 @@ message IrConst {
|
||||
}
|
||||
}
|
||||
|
||||
message IrContinue {
|
||||
required int32 loop_id = 1;
|
||||
optional string label = 2;
|
||||
}
|
||||
|
||||
message IrDelegatingConstructorCall {
|
||||
required KotlinDescriptor descriptor = 1;
|
||||
required MemberAccessCommon member_access = 2;
|
||||
@@ -191,21 +196,22 @@ message IrOperation {
|
||||
IrCall call = 3;
|
||||
IrCallableReference callable_reference = 4;
|
||||
IrConst const = 5;
|
||||
IrDelegatingConstructorCall delegating_constructor_call = 6;
|
||||
IrEnumConstructorCall enum_constructor_call = 7;
|
||||
IrGetEnumValue get_enum_value = 8;
|
||||
IrGetValue get_value = 9;
|
||||
IrGetObject get_object = 10;
|
||||
IrInstanceInitializerCall instance_initializer_call = 11;
|
||||
IrReturn return = 12;
|
||||
IrSetVariable set_variable = 13;
|
||||
IrStringConcat string_concat = 14;
|
||||
IrThrow throw = 15;
|
||||
IrTry try = 16;
|
||||
IrTypeOp type_op = 17;
|
||||
IrVararg vararg = 18;
|
||||
IrWhen when = 19;
|
||||
IrWhile while = 20;
|
||||
IrContinue continue = 6;
|
||||
IrDelegatingConstructorCall delegating_constructor_call = 7;
|
||||
IrEnumConstructorCall enum_constructor_call = 8;
|
||||
IrGetEnumValue get_enum_value = 9;
|
||||
IrGetValue get_value = 10;
|
||||
IrGetObject get_object = 11;
|
||||
IrInstanceInitializerCall instance_initializer_call = 12;
|
||||
IrReturn return = 13;
|
||||
IrSetVariable set_variable = 14;
|
||||
IrStringConcat string_concat = 15;
|
||||
IrThrow throw = 16;
|
||||
IrTry try = 17;
|
||||
IrTypeOp type_op = 18;
|
||||
IrVararg vararg = 19;
|
||||
IrWhen when = 20;
|
||||
IrWhile while = 21;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-1
@@ -372,6 +372,18 @@ internal class IrSerializer(val context: Context,
|
||||
return proto.build()
|
||||
}
|
||||
|
||||
fun serializeContinue(expression: IrContinue): KonanIr.IrContinue {
|
||||
val proto = KonanIr.IrContinue.newBuilder()
|
||||
val label = expression.label
|
||||
if (label != null) {
|
||||
proto.setLabel(label)
|
||||
}
|
||||
val loopId = loopIndex[expression.loop!!]!!
|
||||
proto.setLoopId(loopId)
|
||||
|
||||
return proto.build()
|
||||
}
|
||||
|
||||
fun serializeExpression(expression: IrExpression): KonanIr.IrExpression {
|
||||
context.log("### serializing Expression: ${ir2string(expression)}")
|
||||
|
||||
@@ -389,6 +401,7 @@ internal class IrSerializer(val context: Context,
|
||||
is IrCallableReference
|
||||
-> operationProto.setCallableReference(serializeCallableReference(expression))
|
||||
is IrConst<*> -> operationProto.setConst(serializeConst(expression))
|
||||
is IrContinue -> operationProto.setContinue(serializeContinue(expression))
|
||||
is IrDelegatingConstructorCall
|
||||
-> operationProto.setDelegatingConstructorCall(serializeDelegatingConstructorCall(expression))
|
||||
is IrGetValue -> operationProto.setGetValue(serializeGetValue(expression))
|
||||
@@ -728,7 +741,6 @@ internal class IrDeserializer(val context: Context,
|
||||
return IrInstanceInitializerCallImpl(start, end, descriptor)
|
||||
}
|
||||
|
||||
|
||||
fun deserializeReturn(proto: KonanIr.IrReturn, start: Int, end: Int, type: KotlinType): IrReturn {
|
||||
val descriptor =
|
||||
deserializeDescriptor(proto.getReturnTarget()) as CallableDescriptor
|
||||
@@ -841,6 +853,16 @@ internal class IrDeserializer(val context: Context,
|
||||
return irBreak
|
||||
}
|
||||
|
||||
fun deserializeContinue(proto: KonanIr.IrContinue, start: Int, end: Int, type: KotlinType): IrContinue {
|
||||
val label = if(proto.hasLabel()) proto.getLabel() else null
|
||||
val loopId = proto.getLoopId()
|
||||
val loop = loopIndex[loopId]!!
|
||||
val irContinue = IrContinueImpl(start, end, type, loop)
|
||||
irContinue.label = label
|
||||
|
||||
return irContinue
|
||||
}
|
||||
|
||||
fun deserializeConst(proto: KonanIr.IrConst, start: Int, end: Int, type: KotlinType): IrExpression {
|
||||
|
||||
when {
|
||||
@@ -872,6 +894,8 @@ internal class IrDeserializer(val context: Context,
|
||||
-> return deserializeCallableReference(proto.getCallableReference(), start, end, type)
|
||||
proto.hasConst()
|
||||
-> return deserializeConst(proto.getConst(), start, end, type)
|
||||
proto.hasContinue()
|
||||
-> return deserializeContinue(proto.getContinue(), start, end, type)
|
||||
proto.hasDelegatingConstructorCall()
|
||||
-> return deserializeDelegatingConstructorCall(proto.getDelegatingConstructorCall(), start, end, type)
|
||||
proto.hasGetValue()
|
||||
|
||||
Reference in New Issue
Block a user