Output formatting
This commit is contained in:
committed by
KonstantinAnisimov
parent
bf9cd488ef
commit
ba8621389e
+22
-22
@@ -239,7 +239,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
override fun visitModuleFragment(module: IrModuleFragment) {
|
||||
context.log("visitModule : ${ir2string(module)}")
|
||||
context.log("visitModule : ${ir2string(module)}")
|
||||
|
||||
// computeLifetimes(module, this.codegen, resultLifetimes)
|
||||
|
||||
@@ -356,7 +356,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
override fun visitConstructor(constructorDeclaration: IrConstructor) {
|
||||
context.log("visitConstructor : ${ir2string(constructorDeclaration)}")
|
||||
context.log("visitConstructor : ${ir2string(constructorDeclaration)}")
|
||||
if (constructorDeclaration.descriptor.containingDeclaration.isIntrinsic) {
|
||||
// Do not generate any ctors for intrinsic classes.
|
||||
return
|
||||
@@ -380,7 +380,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer) {
|
||||
context.log("visitAnonymousInitializer : ${ir2string(declaration)}")
|
||||
context.log("visitAnonymousInitializer : ${ir2string(declaration)}")
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
@@ -500,7 +500,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
|
||||
using(FunctionScope(declaration)) {
|
||||
using(VariableScope()) {
|
||||
context.log("generateBlockBody : ${ir2string(body)}")
|
||||
context.log("generateBlockBody : ${ir2string(body)}")
|
||||
when (body) {
|
||||
is IrBlockBody -> body.statements.forEach { generateStatement(it) }
|
||||
is IrExpressionBody -> generateStatement(body.expression)
|
||||
@@ -527,7 +527,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
override fun visitClass(declaration: IrClass) {
|
||||
context.log("visitClass : ${ir2string(declaration)}")
|
||||
context.log("visitClass : ${ir2string(declaration)}")
|
||||
if (declaration.descriptor.kind == ClassKind.ANNOTATION_CLASS) {
|
||||
// do not generate any code for annotation classes as a workaround for NotImplementedError
|
||||
return
|
||||
@@ -551,7 +551,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
override fun visitField(expression: IrField) {
|
||||
context.log("visitField : ${ir2string(expression)}")
|
||||
context.log("visitField : ${ir2string(expression)}")
|
||||
val descriptor = expression.descriptor
|
||||
if (descriptor.containingDeclaration is PackageFragmentDescriptor) {
|
||||
val type = codegen.getLLVMType(descriptor.type)
|
||||
@@ -1016,7 +1016,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
* we cannot determine if the result of when is assigned or not.
|
||||
*/
|
||||
private fun evaluateWhen(expression: IrWhen): LLVMValueRef {
|
||||
context.log("evaluateWhen : ${ir2string(expression)}")
|
||||
context.log("evaluateWhen : ${ir2string(expression)}")
|
||||
var bbExit: LLVMBasicBlockRef? = null // By default "when" does not have "exit".
|
||||
val isUnit = KotlinBuiltIns.isUnit(expression.type)
|
||||
val isNothing = KotlinBuiltIns.isNothing(expression.type)
|
||||
@@ -1102,14 +1102,14 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateGetValue(value: IrGetValue): LLVMValueRef {
|
||||
context.log("evaluateGetValue : ${ir2string(value)}")
|
||||
context.log("evaluateGetValue : ${ir2string(value)}")
|
||||
return currentCodeContext.genGetValue(value.descriptor)
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateSetVariable(value: IrSetVariable): LLVMValueRef {
|
||||
context.log("evaluateSetVariable : ${ir2string(value)}")
|
||||
context.log("evaluateSetVariable : ${ir2string(value)}")
|
||||
val result = evaluateExpression(value.value)
|
||||
val variable = currentCodeContext.getDeclaredVariable(value.descriptor)
|
||||
codegen.vars.store(result, variable)
|
||||
@@ -1121,7 +1121,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun generateVariable(value: IrVariable) {
|
||||
context.log("generateVariable : ${ir2string(value)}")
|
||||
context.log("generateVariable : ${ir2string(value)}")
|
||||
val result = value.initializer?.let { evaluateExpression(it) }
|
||||
currentCodeContext.genDeclareVariable(value.descriptor, result)
|
||||
}
|
||||
@@ -1154,7 +1154,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
}
|
||||
|
||||
private fun evaluateIntegerCoercion(value: IrTypeOperatorCall): LLVMValueRef {
|
||||
context.log("evaluateIntegerCoercion : ${ir2string(value)}")
|
||||
context.log("evaluateIntegerCoercion : ${ir2string(value)}")
|
||||
val type = value.typeOperand
|
||||
assert(type.isPrimitiveInteger())
|
||||
val result = evaluateExpression(value.argument)
|
||||
@@ -1183,7 +1183,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
// double | fptosi fptosi fptosi fptosi fptrunc x
|
||||
|
||||
private fun evaluateCast(value: IrTypeOperatorCall): LLVMValueRef {
|
||||
context.log("evaluateCast : ${ir2string(value)}")
|
||||
context.log("evaluateCast : ${ir2string(value)}")
|
||||
val type = value.typeOperand
|
||||
assert(!KotlinBuiltIns.isPrimitiveType(type) && !KotlinBuiltIns.isPrimitiveType(value.argument.type))
|
||||
assert(!type.isTypeParameter())
|
||||
@@ -1199,7 +1199,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateInstanceOf(value: IrTypeOperatorCall): LLVMValueRef {
|
||||
context.log("evaluateInstanceOf : ${ir2string(value)}")
|
||||
context.log("evaluateInstanceOf : ${ir2string(value)}")
|
||||
|
||||
val type = value.typeOperand
|
||||
val srcArg = evaluateExpression(value.argument) // Evaluate src expression.
|
||||
@@ -1251,7 +1251,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateGetField(value: IrGetField): LLVMValueRef {
|
||||
context.log("evaluateGetField : ${ir2string(value)}")
|
||||
context.log("evaluateGetField : ${ir2string(value)}")
|
||||
if (value.descriptor.dispatchReceiverParameter != null) {
|
||||
val thisPtr = evaluateExpression(value.receiver!!)
|
||||
return codegen.loadSlot(
|
||||
@@ -1279,7 +1279,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateSetField(value: IrSetField): LLVMValueRef {
|
||||
context.log("evaluateSetField : ${ir2string(value)}")
|
||||
context.log("evaluateSetField : ${ir2string(value)}")
|
||||
val valueToAssign = evaluateExpression(value.value)
|
||||
|
||||
if (value.descriptor.dispatchReceiverParameter != null) {
|
||||
@@ -1346,7 +1346,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateConst(value: IrConst<*>): LLVMValueRef {
|
||||
context.log("evaluateConst : ${ir2string(value)}")
|
||||
context.log("evaluateConst : ${ir2string(value)}")
|
||||
when (value.kind) {
|
||||
IrConstKind.Null -> return codegen.kNullObjHeaderPtr
|
||||
IrConstKind.Boolean -> when (value.value) {
|
||||
@@ -1369,7 +1369,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateReturn(expression: IrReturn): LLVMValueRef {
|
||||
context.log("evaluateReturn : ${ir2string(expression)}")
|
||||
context.log("evaluateReturn : ${ir2string(expression)}")
|
||||
val value = expression.value
|
||||
|
||||
val evaluated = evaluateExpression(value)
|
||||
@@ -1424,7 +1424,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateInlineFunction(value: IrInlineFunctionBody): LLVMValueRef {
|
||||
context.log("evaluateInlineFunction : ${value.statements.forEach { ir2string(it) }}")
|
||||
context.log("evaluateInlineFunction : ${value.statements.forEach { ir2string(it) }}")
|
||||
|
||||
val inlinedFunctionScope = InlinedFunctionScope(value)
|
||||
using(inlinedFunctionScope) {
|
||||
@@ -1453,7 +1453,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
private fun evaluateContainerExpression(value: IrContainerExpression): LLVMValueRef {
|
||||
context.log("evaluateContainerExpression : ${value.statements.forEach { ir2string(it) }}")
|
||||
context.log("evaluateContainerExpression : ${value.statements.forEach { ir2string(it) }}")
|
||||
|
||||
val scope = if (value is IrContainerExpression && value.isTransparentScope) {
|
||||
null
|
||||
@@ -1527,7 +1527,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
}
|
||||
|
||||
private fun evaluateCall(value: IrMemberAccessExpression): LLVMValueRef {
|
||||
context.log("evaluateCall : ${ir2string(value)}")
|
||||
context.log("evaluateCall : ${ir2string(value)}")
|
||||
|
||||
val args = evaluateExplicitArgs(value)
|
||||
|
||||
@@ -1652,7 +1652,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
}
|
||||
|
||||
private fun evaluateConstructorCall(callee: IrCall, args: List<LLVMValueRef>): LLVMValueRef {
|
||||
context.log("evaluateConstructorCall : ${ir2string(callee)}")
|
||||
context.log("evaluateConstructorCall : ${ir2string(callee)}")
|
||||
memScoped {
|
||||
val constructedClass = (callee.descriptor as ConstructorDescriptor).constructedClass
|
||||
val thisValue = if (constructedClass.isArray) {
|
||||
@@ -1734,7 +1734,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
|
||||
|
||||
private fun evaluateOperatorCall(callee: IrCall, args: List<LLVMValueRef>): LLVMValueRef {
|
||||
context.log("evaluateCall : origin:${ir2string(callee)}")
|
||||
context.log("evaluateCall : origin:${ir2string(callee)}")
|
||||
val descriptor = callee.descriptor
|
||||
val ib = context.irModule!!.irBuiltins
|
||||
when (descriptor) {
|
||||
|
||||
Reference in New Issue
Block a user