Merge branch 'master' of https://github.com/olonho/carkot
This commit is contained in:
@@ -121,7 +121,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
|
||||
val names = parseValueArguments(targetCall!!.valueArguments, scopeDepth)
|
||||
val args = loadArgsIfRequired(names, constructorArguments)
|
||||
return evaluateConstructorCallExpression(LLVMVariable(structCodegen.fullName + structCodegen.primaryConstructorIndex, structCodegen.type, scope = LLVMVariableScope()), args)
|
||||
return evaluateConstructorCallExpression(LLVMVariable(structCodegen.fullName + LLVMType.mangleFunctionArguments(names), structCodegen.type, scope = LLVMVariableScope()), args)
|
||||
}
|
||||
|
||||
private fun evaluateThisExpression(): LLVMSingleValue? {
|
||||
@@ -246,7 +246,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
|
||||
val function = selector.firstChild.firstChild.text
|
||||
val names = parseArgList(selector, scopeDepth)
|
||||
val type = if (names.size > 0) "_${names.joinToString(separator = "_", transform = { it.type!!.mangle() })}" else ""
|
||||
val type = if (names.size > 0) LLVMType.mangleFunctionArguments(names) else ""
|
||||
val extensionCodegen = state.extensionFunctions[standardType.toString()]?.get("$function$type") ?: throw UnexpectedException("$standardType:$function$type")
|
||||
val receiverExpression = receiverExpressionArgument ?: evaluateExpression(receiver, scopeDepth + 1)!!
|
||||
|
||||
@@ -280,7 +280,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
(call as? KtCallExpression) ?: throw UnexpectedException("$receiver:$selectorName")
|
||||
val names = parseArgList(call as KtCallExpression, scopeDepth)
|
||||
val typePath = type.location.joinToString(".")
|
||||
val types = if (names.size > 0) "_${names.joinToString(separator = "_", transform = { it.type!!.mangle() })}" else ""
|
||||
val types = if (names.size > 0) LLVMType.mangleFunctionArguments(names) else ""
|
||||
val methodName = "${if (typePath.length > 0) "$typePath." else ""}${clazz.structName}.${selectorName.substringBefore('(').trim()}$types"
|
||||
|
||||
val method = clazz.methods[methodName] ?: throw UnexpectedException(methodName)
|
||||
@@ -328,7 +328,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
val targetClassName = (receiver.type as LLVMReferenceType).type
|
||||
|
||||
val names = parseValueArguments(callMaker.valueArguments, scope)
|
||||
val methodName = "$targetClassName.$arrayActionType${if (names.size > 0) "_${names.joinToString(separator = "_", transform = { it.type!!.mangle() })}" else ""}"
|
||||
val methodName = "$targetClassName.$arrayActionType${if (names.size > 0) LLVMType.mangleFunctionArguments(names) else ""}"
|
||||
val type = receiver.type as LLVMReferenceType
|
||||
val clazz = resolveClassOrObjectLocation(type) ?: throw UnexpectedException(type.toString())
|
||||
|
||||
@@ -405,7 +405,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
val names = parseArgList(expr, scopeDepth)
|
||||
var name = expr.firstChild.firstChild.text
|
||||
val external = state.externalFunctions.containsKey(name)
|
||||
val function = "$name${if (names.size > 0 && !external) "_${names.joinToString(separator = "_", transform = { it.type!!.mangle() })}" else ""}"
|
||||
val function = "$name${if (names.size > 0 && !external) LLVMType.mangleFunctionArguments(names) else ""}"
|
||||
|
||||
if (state.functions.containsKey(function) || state.externalFunctions.containsKey(function)) {
|
||||
val descriptor = state.functions[function] ?: state.externalFunctions[function] ?: return null
|
||||
|
||||
@@ -38,7 +38,7 @@ class FunctionCodegen(state: TranslationState,
|
||||
returnType!!.pointer = 2
|
||||
}
|
||||
external = isExternal()
|
||||
name = "${function.fqName}${if (args.size > 0 && !external) "_${args.joinToString(separator = "_", transform = { it.type.mangle() })}" else ""}"
|
||||
name = "${function.fqName}${if (args.size > 0 && !external) LLVMType.mangleFunctionArguments(args) else ""}"
|
||||
|
||||
if (isExtensionDeclaration) {
|
||||
val receiverType = descriptor.extensionReceiverParameter!!.type
|
||||
|
||||
+2
-2
@@ -21,10 +21,10 @@ class LLVMFunctionType(type: KotlinType, state: TranslationState) : LLVMType() {
|
||||
}
|
||||
|
||||
override fun mangle() =
|
||||
"F.${arguments.joinToString(separator = "_", transform = { it.type.mangle() })}.EF"
|
||||
"F.${LLVMType.mangleFunctionArguments(arguments)}.EF"
|
||||
|
||||
fun mangleArgs(): String =
|
||||
if (arguments.size > 0) "_${arguments.joinToString(separator = "_", transform = { it.type.mangle() })}" else ""
|
||||
if (arguments.size > 0) LLVMType.mangleFunctionArguments(arguments) else ""
|
||||
|
||||
override fun toString(): String =
|
||||
"${returnType.type} (${arguments.map { it.getType() }.joinToString()})"
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
secondary_constructor_1_Int(1389) == 1401
|
||||
secondary_constructor_1_arrays() == 57
|
||||
|
||||
@@ -7,4 +7,22 @@ class secondary_constructor_1_class(var field1: Int) {
|
||||
fun secondary_constructor_1(x: Int): Int {
|
||||
val cls = secondary_constructor_1_class(12, x)
|
||||
return cls.field1
|
||||
}
|
||||
}
|
||||
|
||||
class secondary_constructor_1_class2() {
|
||||
var field1: IntArray
|
||||
|
||||
init {
|
||||
field1 = IntArray(0)
|
||||
}
|
||||
|
||||
constructor(x: Int) : this() {
|
||||
this.field1 = this.field1.plus(x)
|
||||
}
|
||||
}
|
||||
|
||||
fun secondary_constructor_1_arrays(): Int {
|
||||
val cls = secondary_constructor_1_class2(56)
|
||||
println(cls.field1)
|
||||
return cls.field1.size + cls.field1[0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user