Non local return implemented
This commit is contained in:
+2
@@ -20,6 +20,7 @@ internal class CodeGenerator(override val context: Context) : ContextUtils {
|
||||
var returnSlot: LLVMValueRef? = null
|
||||
var slotsPhi: LLVMValueRef? = null
|
||||
var slotCount = 0
|
||||
var functionDescriptor: FunctionDescriptor? = null
|
||||
|
||||
fun prologue(descriptor: FunctionDescriptor) {
|
||||
prologue(llvmFunction(descriptor),
|
||||
@@ -27,6 +28,7 @@ internal class CodeGenerator(override val context: Context) : ContextUtils {
|
||||
if (descriptor is ConstructorDescriptor) {
|
||||
constructedClass = descriptor.constructedClass
|
||||
}
|
||||
functionDescriptor = descriptor
|
||||
}
|
||||
|
||||
fun prologue(function:LLVMValueRef, returnType:LLVMTypeRef) {
|
||||
|
||||
+5
@@ -1491,6 +1491,11 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
}
|
||||
|
||||
override fun genReturn(target: CallableDescriptor, value: LLVMValueRef?) {
|
||||
if (target == codegen.functionDescriptor) {
|
||||
super.genReturn(target, value)
|
||||
return
|
||||
}
|
||||
|
||||
if (KotlinBuiltIns.isUnit(inlineBody.type) == false) {
|
||||
codegen.assignPhis(getResult()!! to value!!)
|
||||
}
|
||||
|
||||
+3
-4
@@ -35,7 +35,6 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoid(
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
fun getLambdaStatements(value: IrExpression) : MutableList<IrStatement> {
|
||||
|
||||
val statements = (value as IrContainerExpressionBase).statements
|
||||
val lambdaFunction = statements[0] as IrFunction
|
||||
val lambdaBody = lambdaFunction.body as IrBlockBody
|
||||
@@ -52,11 +51,11 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoid(
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
fun evaluateParameters(callExpression: IrCall,
|
||||
fun evaluateParameters(irCall: IrCall,
|
||||
statements: MutableList<IrStatement>): List<Pair<ParameterDescriptor, IrExpression>> {
|
||||
|
||||
val scope = Scope(callExpression.descriptor as FunctionDescriptor)
|
||||
val parametersOld = callExpression.getArguments() // Create map inline_function_parameter -> containing_function_expression.
|
||||
val scope = Scope(irCall.descriptor as FunctionDescriptor)
|
||||
val parametersOld = irCall.getArguments() // Create map inline_function_parameter -> containing_function_expression.
|
||||
val parametersNew = parametersOld.map {
|
||||
val parameter = it.first
|
||||
val expression = it.second
|
||||
|
||||
Reference in New Issue
Block a user