Comments added. Variables renamed

This commit is contained in:
Konstantin Anisimov
2017-02-03 19:36:01 +07:00
parent 90b12e3041
commit bd129d62c9
2 changed files with 12 additions and 12 deletions
@@ -1512,15 +1512,15 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
} }
override fun genReturn(target: CallableDescriptor, value: LLVMValueRef?) { override fun genReturn(target: CallableDescriptor, value: LLVMValueRef?) {
if (target == codegen.functionDescriptor) { if (target == codegen.functionDescriptor) { // It is "non local return".
super.genReturn(target, value) super.genReturn(target, value) // Generate real "return".
return return
} }
// It is local return.
if (KotlinBuiltIns.isUnit(inlineBody.type) == false) { if (KotlinBuiltIns.isUnit(inlineBody.type) == false) { // If function returns more then "unit"
codegen.assignPhis(getResult()!! to value!!) codegen.assignPhis(getResult()!! to value!!) // Assign return value to resilt PHI node
} }
codegen.br(getExit()!!) codegen.br(getExit()!!) // Generate branch on exit block.
} }
} }
@@ -134,9 +134,9 @@ internal class ParametersTransformer(val parameterToExpression: List <Pair<Param
if ((expression.descriptor as FunctionDescriptor).isFunctionInvoke) { // If it is lambda call. if ((expression.descriptor as FunctionDescriptor).isFunctionInvoke) { // If it is lambda call.
if (expression.dispatchReceiver !is IrGetValue) super.visitCall(expression) // Do not process such dispatch receiver. if (expression.dispatchReceiver !is IrGetValue) super.visitCall(expression) // Do not process such dispatch receiver.
val getValue = expression.dispatchReceiver as IrGetValue // val getValue = expression.dispatchReceiver as IrGetValue //
val parExpr = parameterToExpression.find { it.first == getValue.descriptor } // Find expression to replace this parameter. val parameterExpression = parameterToExpression.find { it.first == getValue.descriptor } // Find expression to replace this parameter.
if (parExpr == null) super.visitCall(expression) // It is not function parameter. if (parameterExpression == null) super.visitCall(expression) // It is not function parameter.
return parExpr!!.second // Replace call site with InlineFunctionBody. return parameterExpression!!.second // Replace call site with InlineFunctionBody.
} }
return super.visitCall(expression) // Function is declared in another module. return super.visitCall(expression) // Function is declared in another module.
} }
@@ -148,9 +148,9 @@ internal class ParametersTransformer(val parameterToExpression: List <Pair<Param
if (descriptor !is ParameterDescriptor) { // TODO do we need this check? if (descriptor !is ParameterDescriptor) { // TODO do we need this check?
return super.visitGetValue(expression) return super.visitGetValue(expression)
} }
val parExp = parameterToExpression.find { it.first == descriptor } // Find expression to replace this parameter. val parameterExpression = parameterToExpression.find { it.first == descriptor } // Find expression to replace this parameter.
if (parExp == null) return super.visitGetValue(expression) if (parameterExpression == null) return super.visitGetValue(expression)
return parExp.second // TODO should we proceed with IR iteration here? return parameterExpression.second // TODO should we proceed with IR iteration here?
} }
} }