translator: fix *this transfer

This commit is contained in:
Alexey Stepanov
2016-07-18 16:39:55 +03:00
parent 8369cecda5
commit 445a19ec26
3 changed files with 20 additions and 1 deletions
@@ -194,9 +194,12 @@ class FunctionCodegen(val state: TranslationState, val variableManager: Variable
val methodName = clazz.clazz.name.toString() + '.' + selectorName.substringBefore('(')
val method = clazz.methods[methodName]!!
val returnType = clazz.methods[methodName]!!.returnType.type
val methodArgs = mutableListOf<LLVMSingleValue>(receiver)
val names = parseArgList(expr.lastChild as KtCallExpression, scopeDepth)
return evaluateFunctionCallExpression(LLVMVariable(methodName, returnType, scope = LLVMRegisterScope()), names, method.args)
methodArgs.addAll(names)
return evaluateFunctionCallExpression(LLVMVariable(methodName, returnType, scope = LLVMVariableScope()), methodArgs, method.args)
}
@@ -0,0 +1 @@
simply_class_1(6789) == 6794
@@ -0,0 +1,15 @@
annotation class Native(val type: String = "")
@Native
class classname_A(@Native("i32") val x: Int) {
fun method(): Int {
return this.x + 5
}
}
fun simply_class_1(zz: Int) : Int{
val x = classname_A(zz)
val r = x.method()
return r
}