translator: basic refactoring whole project
This commit is contained in:
@@ -123,7 +123,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
val targetCall = state.bindingContext.get(BindingContext.CALL, expr)
|
val targetCall = state.bindingContext.get(BindingContext.CALL, expr)
|
||||||
|
|
||||||
val names = parseValueArguments(targetCall!!.valueArguments, scopeDepth)
|
val names = parseValueArguments(targetCall!!.valueArguments, scopeDepth)
|
||||||
val args = loadArgsIfRequired(names, constructorArguments)
|
val args = codeBuilder.loadArgsIfRequired(names, constructorArguments)
|
||||||
return evaluateConstructorCallExpression(LLVMVariable(structCodegen.fullName + LLVMType.mangleFunctionArguments(names), structCodegen.type, scope = LLVMVariableScope()), args)
|
return evaluateConstructorCallExpression(LLVMVariable(structCodegen.fullName + LLVMType.mangleFunctionArguments(names), structCodegen.type, scope = LLVMVariableScope()), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +241,9 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val clazz = resolveCodegen(receiverExpr) ?: return evaluateExtensionExpression(receiverExpr, receiver, selectorExpr as? KtCallExpression ?: throw UnexpectedException(selectorExpr.text), scopeDepth)
|
val clazz = resolveCodegen(receiverExpr)
|
||||||
|
?: return evaluateExtensionExpression(receiverExpr, receiver, selectorExpr as? KtCallExpression
|
||||||
|
?: throw UnexpectedException(selectorExpr.text), scopeDepth)
|
||||||
return evaluateClassScopedDotExpression(clazz, selectorExpr, scopeDepth, receiver)
|
return evaluateClassScopedDotExpression(clazz, selectorExpr, scopeDepth, receiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,15 +263,16 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
}
|
}
|
||||||
|
|
||||||
val args = mutableListOf(codeBuilder.loadArgumentIfRequired(receiverExpression, typeThisArgument))
|
val args = mutableListOf(codeBuilder.loadArgumentIfRequired(receiverExpression, typeThisArgument))
|
||||||
args.addAll(loadArgsIfRequired(names, extensionCodegen.args))
|
args.addAll(codeBuilder.loadArgsIfRequired(names, extensionCodegen.args))
|
||||||
return evaluateFunctionCallExpression(LLVMVariable(extensionCodegen.fullName, extensionCodegen.returnType!!.type, scope = LLVMVariableScope()), args)
|
return evaluateFunctionCallExpression(LLVMVariable(extensionCodegen.fullName, extensionCodegen.returnType!!.type, scope = LLVMVariableScope()), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun evaluateClassScopedDotExpression(clazz: StructCodegen, selector: KtExpression, scopeDepth: Int, receiver: LLVMVariable? = null): LLVMSingleValue? = when (selector) {
|
private fun evaluateClassScopedDotExpression(clazz: StructCodegen, selector: KtExpression, scopeDepth: Int, receiver: LLVMVariable? = null): LLVMSingleValue? =
|
||||||
is KtCallExpression -> evaluateCallExpression(selector, scopeDepth, clazz, caller = receiver)
|
when (selector) {
|
||||||
is KtReferenceExpression -> evaluateReferenceExpression(selector, scopeDepth, clazz)
|
is KtCallExpression -> evaluateCallExpression(selector, scopeDepth, clazz, caller = receiver)
|
||||||
else -> throw UnsupportedOperationException()
|
is KtReferenceExpression -> evaluateReferenceExpression(selector, scopeDepth, clazz)
|
||||||
}
|
else -> throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
fun evaluateMemberMethodOrField(receiver: LLVMVariable, selectorName: String, scopeDepth: Int, call: PsiElement? = null): LLVMSingleValue? {
|
fun evaluateMemberMethodOrField(receiver: LLVMVariable, selectorName: String, scopeDepth: Int, call: PsiElement? = null): LLVMSingleValue? {
|
||||||
val type = receiver.type as LLVMReferenceType
|
val type = receiver.type as LLVMReferenceType
|
||||||
@@ -291,7 +294,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
val method = clazz.methods[methodName] ?: throw UnexpectedException(methodName)
|
val method = clazz.methods[methodName] ?: throw UnexpectedException(methodName)
|
||||||
val returnType = clazz.methods[methodName]!!.returnType!!.type
|
val returnType = clazz.methods[methodName]!!.returnType!!.type
|
||||||
|
|
||||||
val loadedArgs = loadArgsIfRequired(names, method.args)
|
val loadedArgs = codeBuilder.loadArgsIfRequired(names, method.args)
|
||||||
val callArgs = mutableListOf<LLVMSingleValue>(receiver)
|
val callArgs = mutableListOf<LLVMSingleValue>(receiver)
|
||||||
callArgs.addAll(loadedArgs)
|
callArgs.addAll(loadedArgs)
|
||||||
|
|
||||||
@@ -340,13 +343,13 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
val method = clazz.methods[methodName] ?: throw UnexpectedException(expr.text)
|
val method = clazz.methods[methodName] ?: throw UnexpectedException(expr.text)
|
||||||
val returnType = clazz.methods[methodName]!!.returnType!!.type
|
val returnType = clazz.methods[methodName]!!.returnType!!.type
|
||||||
|
|
||||||
val loadedArgs = loadArgsIfRequired(names, method.args)
|
val loadedArgs = codeBuilder.loadArgsIfRequired(names, method.args)
|
||||||
val callArgs = mutableListOf(pureReceiver)
|
val callArgs = mutableListOf(pureReceiver)
|
||||||
callArgs.addAll(loadedArgs)
|
callArgs.addAll(loadedArgs)
|
||||||
|
|
||||||
return evaluateFunctionCallExpression(LLVMVariable(methodName, returnType, scope = LLVMVariableScope()), callArgs)
|
return evaluateFunctionCallExpression(LLVMVariable(methodName, returnType, scope = LLVMVariableScope()), callArgs)
|
||||||
}
|
}
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException("Unknown array access method")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
@@ -360,17 +363,18 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun evaluateReferenceExpression(expr: KtReferenceExpression, scopeDepth: Int, classScope: StructCodegen? = null): LLVMSingleValue? = when {
|
private fun evaluateReferenceExpression(expr: KtReferenceExpression, scopeDepth: Int, classScope: StructCodegen? = null): LLVMSingleValue? =
|
||||||
expr is KtArrayAccessExpression -> evaluateArrayAccessExpression(expr, scopeDepth + 1)
|
when {
|
||||||
isEnumClassField(expr, classScope) -> resolveEnumClassField(expr, classScope)
|
expr is KtArrayAccessExpression -> evaluateArrayAccessExpression(expr, scopeDepth + 1)
|
||||||
variableManager[expr.firstChild.text] != null -> variableManager[expr.firstChild.text]
|
isEnumClassField(expr, classScope) -> resolveEnumClassField(expr, classScope)
|
||||||
(expr is KtNameReferenceExpression) && (classScope != null) -> evaluateNameReferenceExpression(expr, classScope.parentCodegen!!)
|
variableManager[expr.firstChild.text] != null -> variableManager[expr.firstChild.text]
|
||||||
else -> {
|
(expr is KtNameReferenceExpression) && (classScope != null) -> evaluateNameReferenceExpression(expr, classScope.parentCodegen!!)
|
||||||
val clazz = resolveCodegen(expr)
|
else -> {
|
||||||
val receiver = if (clazz != null) variableManager[clazz.fullName] ?: variableManager["this"] else variableManager["this"]
|
val clazz = resolveCodegen(expr)
|
||||||
evaluateMemberMethodOrField(receiver!!, expr.firstChild.text, topLevel)
|
val receiver = if (clazz != null) variableManager[clazz.fullName] ?: variableManager["this"] else variableManager["this"]
|
||||||
}
|
evaluateMemberMethodOrField(receiver!!, expr.firstChild.text, topLevel)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun evaluateNameReferenceExpression(expr: KtNameReferenceExpression, classScope: StructCodegen): LLVMSingleValue? {
|
private fun evaluateNameReferenceExpression(expr: KtNameReferenceExpression, classScope: StructCodegen): LLVMSingleValue? {
|
||||||
val fieldName = state.bindingContext.get(BindingContext.REFERENCE_TARGET, expr)!!.name.toString()
|
val fieldName = state.bindingContext.get(BindingContext.REFERENCE_TARGET, expr)!!.name.toString()
|
||||||
@@ -422,21 +426,21 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
if (state.functions.containsKey(function) || state.externalFunctions.containsKey(function)) {
|
if (state.functions.containsKey(function) || state.externalFunctions.containsKey(function)) {
|
||||||
val descriptor = state.functions[function] ?: state.externalFunctions[function] ?: return null
|
val descriptor = state.functions[function] ?: state.externalFunctions[function] ?: return null
|
||||||
names = parseNamedValueArguments(arguments, descriptor.defaultValues, scopeDepth)
|
names = parseNamedValueArguments(arguments, descriptor.defaultValues, scopeDepth)
|
||||||
val args = loadArgsIfRequired(names, descriptor.args)
|
val args = codeBuilder.loadArgsIfRequired(names, descriptor.args)
|
||||||
return evaluateFunctionCallExpression(LLVMVariable(function, descriptor.returnType!!.type, scope = LLVMVariableScope()), args)
|
return evaluateFunctionCallExpression(LLVMVariable(function, descriptor.returnType!!.type, scope = LLVMVariableScope()), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.classes.containsKey(name) || classScope?.structName == name) {
|
if (state.classes.containsKey(name) || classScope?.structName == name) {
|
||||||
val descriptor = state.classes[name] ?: classScope ?: return null
|
val descriptor = state.classes[name] ?: classScope ?: return null
|
||||||
val detectedConstructor = LLVMType.mangleFunctionTypes(functionArguments)
|
val detectedConstructor = LLVMType.mangleFunctionTypes(functionArguments)
|
||||||
val args = loadArgsIfRequired(names, descriptor.constructorFields[detectedConstructor]!!)
|
val args = codeBuilder.loadArgsIfRequired(names, descriptor.constructorFields[detectedConstructor]!!)
|
||||||
return evaluateConstructorCallExpression(LLVMVariable(descriptor.fullName + detectedConstructor, descriptor.type, scope = LLVMVariableScope()), args)
|
return evaluateConstructorCallExpression(LLVMVariable(descriptor.fullName + detectedConstructor, descriptor.type, scope = LLVMVariableScope()), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
val localFunction = variableManager[name]
|
val localFunction = variableManager[name]
|
||||||
if (localFunction != null) {
|
if (localFunction != null) {
|
||||||
val type = localFunction.type as LLVMFunctionType
|
val type = localFunction.type as LLVMFunctionType
|
||||||
val args = loadArgsIfRequired(names, type.arguments)
|
val args = codeBuilder.loadArgsIfRequired(names, type.arguments)
|
||||||
return evaluateFunctionCallExpression(LLVMVariable(name, type.returnType.type, scope = LLVMRegisterScope()), args)
|
return evaluateFunctionCallExpression(LLVMVariable(name, type.returnType.type, scope = LLVMRegisterScope()), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +452,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
val receiver = variableManager[parentDescriptor.fullName] ?: throw UnexpectedException(parentDescriptor.fullName)
|
val receiver = variableManager[parentDescriptor.fullName] ?: throw UnexpectedException(parentDescriptor.fullName)
|
||||||
val methodFullName = descriptor.name
|
val methodFullName = descriptor.name
|
||||||
val returnType = descriptor.returnType!!.type
|
val returnType = descriptor.returnType!!.type
|
||||||
val loadedArgs = loadArgsIfRequired(names, descriptor.args)
|
val loadedArgs = codeBuilder.loadArgsIfRequired(names, descriptor.args)
|
||||||
val callArgs = mutableListOf<LLVMSingleValue>(receiver)
|
val callArgs = mutableListOf<LLVMSingleValue>(receiver)
|
||||||
callArgs.addAll(loadedArgs)
|
callArgs.addAll(loadedArgs)
|
||||||
|
|
||||||
@@ -458,7 +462,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
|
|
||||||
val nestedConstructor = classScope?.nestedClasses?.get(expr.calleeExpression!!.text)
|
val nestedConstructor = classScope?.nestedClasses?.get(expr.calleeExpression!!.text)
|
||||||
if (nestedConstructor != null) {
|
if (nestedConstructor != null) {
|
||||||
val args = loadArgsIfRequired(names, nestedConstructor.constructorFields[nestedConstructor.primaryConstructorIndex]!!)
|
val args = codeBuilder.loadArgsIfRequired(names, nestedConstructor.constructorFields[nestedConstructor.primaryConstructorIndex]!!)
|
||||||
return evaluateConstructorCallExpression(LLVMVariable(nestedConstructor.fullName, nestedConstructor.type, scope = LLVMVariableScope()), args)
|
return evaluateConstructorCallExpression(LLVMVariable(nestedConstructor.fullName, nestedConstructor.type, scope = LLVMVariableScope()), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +479,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
args.add(variableManager["this"]!!)
|
args.add(variableManager["this"]!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
args.addAll(loadArgsIfRequired(names, method.args))
|
args.addAll(codeBuilder.loadArgsIfRequired(names, method.args))
|
||||||
|
|
||||||
return evaluateFunctionCallExpression(LLVMVariable(method.fullName, method.returnType?.type ?: LLVMVoidType(), scope = LLVMVariableScope()), args)
|
return evaluateFunctionCallExpression(LLVMVariable(method.fullName, method.returnType?.type ?: LLVMVoidType(), scope = LLVMVariableScope()), args)
|
||||||
}
|
}
|
||||||
@@ -526,14 +530,10 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
return resultPtr
|
return resultPtr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadArgsIfRequired(names: List<LLVMSingleValue>, args: List<LLVMVariable>) =
|
|
||||||
names.mapIndexed(fun(i: Int, value: LLVMSingleValue): LLVMSingleValue {
|
|
||||||
return codeBuilder.loadArgumentIfRequired(value, args[i])
|
|
||||||
}).toList()
|
|
||||||
|
|
||||||
private fun evaluateConstructorCallExpression(function: LLVMVariable, names: List<LLVMSingleValue>): LLVMSingleValue? {
|
private fun evaluateConstructorCallExpression(function: LLVMVariable, names: List<LLVMSingleValue>): LLVMSingleValue? {
|
||||||
val store = codeBuilder.getNewVariable(function.type)
|
val store = codeBuilder.getNewVariable(function.type)
|
||||||
codeBuilder.allocStaticVar(store)
|
codeBuilder.allocStaticVar(store)
|
||||||
@@ -610,7 +610,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
private fun evaluatePostfixExpression(expr: KtPostfixExpression, scopeDepth: Int): LLVMSingleValue? {
|
private fun evaluatePostfixExpression(expr: KtPostfixExpression, scopeDepth: Int): LLVMSingleValue? {
|
||||||
val operator = expr.operationToken
|
val operator = expr.operationToken
|
||||||
val left = evaluateExpression(expr.baseExpression, scopeDepth) ?: throw UnsupportedOperationException("Wrong binary exception: ${expr.text}")
|
val left = evaluateExpression(expr.baseExpression, scopeDepth) ?: throw UnsupportedOperationException("Wrong binary exception: ${expr.text}")
|
||||||
return executePostfixExpression(operator, expr.operationReference, left as LLVMVariable)
|
return executePostfixExpression(operator, left as LLVMVariable)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun evaluatePrefixExpression(expr: KtPrefixExpression, scopeDepth: Int): LLVMSingleValue? {
|
private fun evaluatePrefixExpression(expr: KtPrefixExpression, scopeDepth: Int): LLVMSingleValue? {
|
||||||
@@ -619,13 +619,13 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
return executePrefixExpression(operator, expr.operationReference, left)
|
return executePrefixExpression(operator, expr.operationReference, left)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun executePostfixExpression(operator: IElementType?, operationReference: KtSimpleNameExpression, left: LLVMVariable): LLVMSingleValue?
|
private fun executePostfixExpression(operator: IElementType?, left: LLVMVariable): LLVMSingleValue?
|
||||||
= addPrimitivePostfixOperation(operator, operationReference, left)
|
= addPrimitivePostfixOperation(operator, left)
|
||||||
|
|
||||||
private fun executePrefixExpression(operator: IElementType?, operationReference: KtSimpleNameExpression, left: LLVMSingleValue): LLVMSingleValue?
|
private fun executePrefixExpression(operator: IElementType?, operationReference: KtSimpleNameExpression, left: LLVMSingleValue): LLVMSingleValue?
|
||||||
= addPrimitivePrefixOperation(operator, operationReference, left)
|
= addPrimitivePrefixOperation(operator, operationReference, left)
|
||||||
|
|
||||||
private fun addPrimitivePostfixOperation(operator: IElementType?, operationReference: KtSimpleNameExpression, firstOp: LLVMVariable): LLVMSingleValue? {
|
private fun addPrimitivePostfixOperation(operator: IElementType?, firstOp: LLVMVariable): LLVMSingleValue? {
|
||||||
val firstNativeOp = codeBuilder.receiveNativeValue(firstOp)
|
val firstNativeOp = codeBuilder.receiveNativeValue(firstOp)
|
||||||
when (operator) {
|
when (operator) {
|
||||||
KtTokens.PLUSPLUS, KtTokens.MINUSMINUS -> {
|
KtTokens.PLUSPLUS, KtTokens.MINUSMINUS -> {
|
||||||
@@ -647,7 +647,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
}
|
}
|
||||||
KtTokens.EXCLEXCL -> {
|
KtTokens.EXCLEXCL -> {
|
||||||
var result = firstOp
|
var result = firstOp
|
||||||
codeBuilder.addComment("start EXCLEXCL")
|
codeBuilder.addComment("start EXCLEXCL postfix operator")
|
||||||
val nullLabel = codeBuilder.getNewLabel(prefix = "nullCheck")
|
val nullLabel = codeBuilder.getNewLabel(prefix = "nullCheck")
|
||||||
val notNullLabel = codeBuilder.getNewLabel(prefix = "nullCheck")
|
val notNullLabel = codeBuilder.getNewLabel(prefix = "nullCheck")
|
||||||
val nullCheck = codeBuilder.nullCheck(firstOp)
|
val nullCheck = codeBuilder.nullCheck(firstOp)
|
||||||
@@ -659,7 +659,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
if (firstOp.type.isPrimitive()) {
|
if (firstOp.type.isPrimitive()) {
|
||||||
result = codeBuilder.downLoadArgument(firstOp, 0) as LLVMVariable
|
result = codeBuilder.downLoadArgument(firstOp, 0) as LLVMVariable
|
||||||
}
|
}
|
||||||
codeBuilder.addComment("end EXCLEXCL")
|
codeBuilder.addComment("end EXCLEXCL postfix operator")
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
else -> throw UnsupportedOperationException()
|
else -> throw UnsupportedOperationException()
|
||||||
@@ -1108,8 +1108,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
|
|
||||||
val primitivePointer = LLVMMapStandardType(variable.type, state) !is LLVMReferred
|
val primitivePointer = LLVMMapStandardType(variable.type, state) !is LLVMReferred
|
||||||
|
|
||||||
val allocVar = variableManager.receiveVariable(identifier, expectedExpressionType.type, LLVMRegisterScope(), pointer =
|
val allocVar = variableManager.receiveVariable(identifier, expectedExpressionType.type, LLVMRegisterScope(), pointer = expectedExpressionType.pointer)
|
||||||
expectedExpressionType.pointer)
|
|
||||||
codeBuilder.allocStackVar(allocVar)
|
codeBuilder.allocStackVar(allocVar)
|
||||||
allocVar.pointer++
|
allocVar.pointer++
|
||||||
allocVar.kotlinName = identifier
|
allocVar.kotlinName = identifier
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class ClassCodegen(state: TranslationState,
|
|||||||
val clazz: KtClass,
|
val clazz: KtClass,
|
||||||
codeBuilder: LLVMBuilder,
|
codeBuilder: LLVMBuilder,
|
||||||
parentCodegen: StructCodegen? = null) :
|
parentCodegen: StructCodegen? = null) :
|
||||||
|
StructCodegen(state, variableManager, clazz, codeBuilder, parentCodegen) {
|
||||||
StructCodegen(state, variableManager, clazz, state.bindingContext.get(BindingContext.CLASS, clazz) ?: throw TranslationException(), codeBuilder, parentCodegen) {
|
|
||||||
|
|
||||||
val annotation: Boolean
|
val annotation: Boolean
|
||||||
val enum: Boolean
|
val enum: Boolean
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.kotlinnative.translator
|
package org.kotlinnative.translator
|
||||||
|
|
||||||
import org.jetbrains.kotlin.codegen.StackValue
|
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
import org.jetbrains.kotlin.psi.KtParameter
|
||||||
@@ -8,8 +7,6 @@ import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComme
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
||||||
import org.jetbrains.org.objectweb.asm.Label
|
|
||||||
import org.jetbrains.org.objectweb.asm.Type
|
|
||||||
import org.kotlinnative.translator.llvm.*
|
import org.kotlinnative.translator.llvm.*
|
||||||
import org.kotlinnative.translator.llvm.types.LLVMFunctionType
|
import org.kotlinnative.translator.llvm.types.LLVMFunctionType
|
||||||
import org.kotlinnative.translator.llvm.types.LLVMReferenceType
|
import org.kotlinnative.translator.llvm.types.LLVMReferenceType
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.kotlinnative.translator
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
import org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.kotlinnative.translator.exceptions.TranslationException
|
|
||||||
import org.kotlinnative.translator.llvm.LLVMBuilder
|
import org.kotlinnative.translator.llvm.LLVMBuilder
|
||||||
import org.kotlinnative.translator.llvm.LLVMVariable
|
import org.kotlinnative.translator.llvm.LLVMVariable
|
||||||
import org.kotlinnative.translator.llvm.LLVMVariableScope
|
import org.kotlinnative.translator.llvm.LLVMVariableScope
|
||||||
@@ -14,8 +13,7 @@ class ObjectCodegen(state: TranslationState,
|
|||||||
val objectDeclaration: KtObjectDeclaration,
|
val objectDeclaration: KtObjectDeclaration,
|
||||||
codeBuilder: LLVMBuilder,
|
codeBuilder: LLVMBuilder,
|
||||||
parentCodegen: StructCodegen? = null) :
|
parentCodegen: StructCodegen? = null) :
|
||||||
StructCodegen(state, variableManager, objectDeclaration, state.bindingContext.get(BindingContext.CLASS, objectDeclaration) ?: throw TranslationException(),
|
StructCodegen(state, variableManager, objectDeclaration, codeBuilder, parentCodegen = parentCodegen) {
|
||||||
codeBuilder, parentCodegen = parentCodegen) {
|
|
||||||
override var size: Int = 0
|
override var size: Int = 0
|
||||||
override val structName: String = objectDeclaration.name!!
|
override val structName: String = objectDeclaration.name!!
|
||||||
override val type: LLVMReferenceType
|
override val type: LLVMReferenceType
|
||||||
|
|||||||
@@ -25,5 +25,4 @@ class PropertyCodegen(val state: TranslationState, val variableManager: Variable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.kotlinnative.translator
|
package org.kotlinnative.translator
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
@@ -16,7 +15,6 @@ import java.util.*
|
|||||||
abstract class StructCodegen(val state: TranslationState,
|
abstract class StructCodegen(val state: TranslationState,
|
||||||
val variableManager: VariableManager,
|
val variableManager: VariableManager,
|
||||||
val classOrObject: KtClassOrObject,
|
val classOrObject: KtClassOrObject,
|
||||||
val classDescriptor: ClassDescriptor,
|
|
||||||
val codeBuilder: LLVMBuilder,
|
val codeBuilder: LLVMBuilder,
|
||||||
val parentCodegen: StructCodegen? = null) {
|
val parentCodegen: StructCodegen? = null) {
|
||||||
|
|
||||||
@@ -219,13 +217,13 @@ abstract class StructCodegen(val state: TranslationState,
|
|||||||
codeBuilder.storeVariable(classField, argument)
|
codeBuilder.storeVariable(classField, argument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val blockCodegen = object : BlockCodegen(state, variableManager, codeBuilder) {}
|
val blockCodegen = object : BlockCodegen(state, variableManager, codeBuilder) {}
|
||||||
val receiverThis = LLVMVariable("classvariable.this.addr", type, scope = LLVMRegisterScope(), pointer = 1)
|
val receiverThis = LLVMVariable("classvariable.this.addr", type, scope = LLVMRegisterScope(), pointer = 1)
|
||||||
codeBuilder.addComment("field initilizers starts")
|
codeBuilder.addComment("field initilizers starts")
|
||||||
variableManager.addVariable("this", receiverThis, 2)
|
variableManager.addVariable("this", receiverThis, 2)
|
||||||
|
|
||||||
for ((variable, initializer) in initializedFields) {
|
for ((variable, initializer) in initializedFields) {
|
||||||
val left = blockCodegen.evaluateMemberMethodOrField(receiverThis, variable.label, blockCodegen.topLevel, call = null)!!
|
val left = blockCodegen.evaluateMemberMethodOrField(receiverThis, variable.label, blockCodegen.topLevel, call = null)!!
|
||||||
codeBuilder.addComment("left expression")
|
codeBuilder.addComment("left expression")
|
||||||
@@ -234,6 +232,7 @@ abstract class StructCodegen(val state: TranslationState,
|
|||||||
blockCodegen.executeBinaryExpression(KtTokens.EQ, referenceName = null, left = left, right = right)
|
blockCodegen.executeBinaryExpression(KtTokens.EQ, referenceName = null, left = left, right = right)
|
||||||
codeBuilder.addComment("next initializer")
|
codeBuilder.addComment("next initializer")
|
||||||
}
|
}
|
||||||
|
|
||||||
variableManager.pullOneUpwardLevelVariable("this")
|
variableManager.pullOneUpwardLevelVariable("this")
|
||||||
codeBuilder.addComment("field initilizers ends")
|
codeBuilder.addComment("field initilizers ends")
|
||||||
}
|
}
|
||||||
@@ -249,7 +248,6 @@ abstract class StructCodegen(val state: TranslationState,
|
|||||||
|
|
||||||
protected fun resolveType(field: KtNamedDeclaration, ktType: KotlinType): LLVMClassVariable {
|
protected fun resolveType(field: KtNamedDeclaration, ktType: KotlinType): LLVMClassVariable {
|
||||||
val annotations = parseFieldAnnotations(field)
|
val annotations = parseFieldAnnotations(field)
|
||||||
|
|
||||||
val result = LLVMInstanceOfStandardType(field.name!!, ktType, LLVMRegisterScope(), state = state)
|
val result = LLVMInstanceOfStandardType(field.name!!, ktType, LLVMRegisterScope(), state = state)
|
||||||
|
|
||||||
if (result.type is LLVMReferenceType) {
|
if (result.type is LLVMReferenceType) {
|
||||||
@@ -262,7 +260,6 @@ abstract class StructCodegen(val state: TranslationState,
|
|||||||
return LLVMClassVariable(result.label, state.classes[field.name!!]!!.type, result.pointer)
|
return LLVMClassVariable(result.label, state.classes[field.name!!]!!.type, result.pointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (annotations.contains("Plain")) {
|
if (annotations.contains("Plain")) {
|
||||||
result.pointer = 0
|
result.pointer = 0
|
||||||
}
|
}
|
||||||
@@ -292,6 +289,5 @@ abstract class StructCodegen(val state: TranslationState,
|
|||||||
}
|
}
|
||||||
blockCodegen.generate(init.body)
|
blockCodegen.generate(init.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.kotlinnative.translator.llvm.LLVMBuilder
|
|||||||
import org.kotlinnative.translator.llvm.LLVMVariable
|
import org.kotlinnative.translator.llvm.LLVMVariable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class TranslationState(val environment: KotlinCoreEnvironment, val bindingContext: BindingContext, val arm: Boolean) {
|
class TranslationState(val environment: KotlinCoreEnvironment, val bindingContext: BindingContext, arm: Boolean) {
|
||||||
companion object {
|
companion object {
|
||||||
var pointerAlign = 4
|
var pointerAlign = 4
|
||||||
var pointerSize = 4
|
var pointerSize = 4
|
||||||
@@ -45,6 +45,7 @@ class TranslationState(val environment: KotlinCoreEnvironment, val bindingContex
|
|||||||
val codeBuilder = LLVMBuilder(arm)
|
val codeBuilder = LLVMBuilder(arm)
|
||||||
|
|
||||||
val extensionFunctions = HashMap<String, HashMap<String, FunctionCodegen>>()
|
val extensionFunctions = HashMap<String, HashMap<String, FunctionCodegen>>()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseAndAnalyze(sources: List<String>, disposer: Disposable, arm: Boolean = false): TranslationState {
|
fun parseAndAnalyze(sources: List<String>, disposer: Disposable, arm: Boolean = false): TranslationState {
|
||||||
@@ -98,7 +99,7 @@ fun analyze(environment: KotlinCoreEnvironment): AnalysisResult? {
|
|||||||
val files = environment.configuration.jvmClasspathRoots
|
val files = environment.configuration.jvmClasspathRoots
|
||||||
val runtimes = files.map { it.canonicalFile }.filter { it.name == PathUtil.KOTLIN_JAVA_RUNTIME_JAR && it.exists() }
|
val runtimes = files.map { it.canonicalFile }.filter { it.name == PathUtil.KOTLIN_JAVA_RUNTIME_JAR && it.exists() }
|
||||||
collector.report(CompilerMessageSeverity.ERROR, runtimes.joinToString { it.path }, CompilerMessageLocation.NO_LOCATION)
|
collector.report(CompilerMessageSeverity.ERROR, runtimes.joinToString { it.path }, CompilerMessageLocation.NO_LOCATION)
|
||||||
println(runtimes.joinToString { it.toString() })
|
System.err.println(runtimes.joinToString { it.toString() })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ class LLVMBuilder(val arm: Boolean = false) {
|
|||||||
else -> throw UnsupportedOperationException()
|
else -> throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun loadArgsIfRequired(names: List<LLVMSingleValue>, args: List<LLVMVariable>) =
|
||||||
|
names.mapIndexed(fun(i: Int, value: LLVMSingleValue): LLVMSingleValue {
|
||||||
|
return loadArgumentIfRequired(value, args[i])
|
||||||
|
}).toList()
|
||||||
|
|
||||||
fun loadArgumentIfRequired(value: LLVMSingleValue, argument: LLVMVariable): LLVMSingleValue {
|
fun loadArgumentIfRequired(value: LLVMSingleValue, argument: LLVMVariable): LLVMSingleValue {
|
||||||
var result = value
|
var result = value
|
||||||
|
|
||||||
@@ -238,11 +243,6 @@ class LLVMBuilder(val arm: Boolean = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addConstant(allocVariable: LLVMVariable, constantValue: LLVMConstant) {
|
|
||||||
localCode.appendln("$allocVariable = alloca ${allocVariable.type}, align ${allocVariable.type.align}")
|
|
||||||
localCode.appendln("store ${allocVariable.type} $constantValue, ${allocVariable.getType()} $allocVariable, align ${allocVariable.type.align}")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun defineGlobalVariable(variable: LLVMVariable, defaultValue: String = variable.type.defaultValue) {
|
fun defineGlobalVariable(variable: LLVMVariable, defaultValue: String = variable.type.defaultValue) {
|
||||||
localCode.appendln("$variable = global ${variable.getType()} $defaultValue, align ${variable.type.align}")
|
localCode.appendln("$variable = global ${variable.getType()} $defaultValue, align ${variable.type.align}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package org.kotlinnative.translator.llvm
|
|||||||
|
|
||||||
import org.kotlinnative.translator.llvm.types.LLVMType
|
import org.kotlinnative.translator.llvm.types.LLVMType
|
||||||
|
|
||||||
open class LLVMConstant(value: String, override val type: LLVMType? = null, override var pointer: Int = 0) : LLVMSingleValue(type, pointer) {
|
open class LLVMConstant(value: String,
|
||||||
|
type: LLVMType? = null,
|
||||||
|
pointer: Int = 0) : LLVMSingleValue(type, pointer) {
|
||||||
val value: String
|
val value: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -12,4 +14,5 @@ open class LLVMConstant(value: String, override val type: LLVMType? = null, over
|
|||||||
override fun getType(): String = type.toString() + "*".repeat(pointer)
|
override fun getType(): String = type.toString() + "*".repeat(pointer)
|
||||||
|
|
||||||
override fun toString(): String = value
|
override fun toString(): String = value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ package org.kotlinnative.translator.llvm
|
|||||||
class LLVMLabel(val label: String, val scope: LLVMScope) : LLVMNode() {
|
class LLVMLabel(val label: String, val scope: LLVMScope) : LLVMNode() {
|
||||||
|
|
||||||
override fun toString(): String = "$scope$label"
|
override fun toString(): String = "$scope$label"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,4 +6,5 @@ import org.kotlinnative.translator.llvm.types.LLVMType
|
|||||||
open class LLVMSingleValue(open val type: LLVMType? = null, open var pointer: Int = 0) : LLVMNode() {
|
open class LLVMSingleValue(open val type: LLVMType? = null, open var pointer: Int = 0) : LLVMNode() {
|
||||||
|
|
||||||
open fun getType(): String = throw UnimplementedException()
|
open fun getType(): String = throw UnimplementedException()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,14 @@ package org.kotlinnative.translator.llvm
|
|||||||
|
|
||||||
import org.kotlinnative.translator.llvm.types.LLVMType
|
import org.kotlinnative.translator.llvm.types.LLVMType
|
||||||
|
|
||||||
open class LLVMVariable(val label: String, override val type: LLVMType, var kotlinName: String? = null, val scope: LLVMScope = LLVMRegisterScope(), override var pointer: Int = 0) : LLVMSingleValue() {
|
open class LLVMVariable(val label: String,
|
||||||
|
override val type: LLVMType,
|
||||||
|
var kotlinName: String? = null,
|
||||||
|
val scope: LLVMScope = LLVMRegisterScope(),
|
||||||
|
pointer: Int = 0) : LLVMSingleValue(type, pointer) {
|
||||||
|
|
||||||
override fun getType(): String = type.toString() + "*".repeat(pointer)
|
override fun getType(): String = type.toString() + "*".repeat(pointer)
|
||||||
|
|
||||||
override fun toString(): String = "$scope$label"
|
override fun toString(): String = "$scope$label"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ fun null_comparison_1_reassigned(): Int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun null_comparison_1_declaration(): Int {
|
fun null_comparison_1_declaration(): Int {
|
||||||
var a: null_comparison_1_class?
|
val a: null_comparison_1_class?
|
||||||
a = null_comparison_1_getClass()
|
a = null_comparison_1_getClass()
|
||||||
if (a == null) {
|
if (a == null) {
|
||||||
return 87
|
return 87
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fun nullable_primitive_types_1_if_not_null(): Int {
|
|||||||
fun nullable_primitive_types_1_reassignment(): Int {
|
fun nullable_primitive_types_1_reassignment(): Int {
|
||||||
var z: Int? = 32
|
var z: Int? = 32
|
||||||
z = null
|
z = null
|
||||||
var r = z
|
val r = z
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
return 5678
|
return 5678
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ class CrossBranch private constructor () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getSizeNoTag(): Int {
|
fun getSizeNoTag(): Int {
|
||||||
var size = 0
|
val size = 0
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ class CrossBranch private constructor () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getSizeNoTag(): Int {
|
fun getSizeNoTag(): Int {
|
||||||
var size = 0
|
val size = 0
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -955,7 +955,7 @@ class CrossBranch private constructor () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getSizeNoTag(): Int {
|
fun getSizeNoTag(): Int {
|
||||||
var size = 0
|
val size = 0
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1008,7 +1008,7 @@ class CrossBranch private constructor () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getSizeNoTag(): Int {
|
fun getSizeNoTag(): Int {
|
||||||
var size = 0
|
val size = 0
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ class MessageRepeatedVarints private constructor (var int: IntArray, var long: L
|
|||||||
readSize += WireFormat.getInt32SizeNoTag(tmp)
|
readSize += WireFormat.getInt32SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = IntArray(arraySize)
|
val newArray = IntArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -753,7 +753,7 @@ class MessageRepeatedVarints private constructor (var int: IntArray, var long: L
|
|||||||
readSize += WireFormat.getInt64SizeNoTag(tmp)
|
readSize += WireFormat.getInt64SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = LongArray(arraySize)
|
val newArray = LongArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -782,7 +782,7 @@ class MessageRepeatedVarints private constructor (var int: IntArray, var long: L
|
|||||||
readSize += WireFormat.getSInt32SizeNoTag(tmp)
|
readSize += WireFormat.getSInt32SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = IntArray(arraySize)
|
val newArray = IntArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -811,7 +811,7 @@ class MessageRepeatedVarints private constructor (var int: IntArray, var long: L
|
|||||||
readSize += WireFormat.getSInt64SizeNoTag(tmp)
|
readSize += WireFormat.getSInt64SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = LongArray(arraySize)
|
val newArray = LongArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -840,7 +840,7 @@ class MessageRepeatedVarints private constructor (var int: IntArray, var long: L
|
|||||||
readSize += WireFormat.getBoolSizeNoTag(tmp)
|
readSize += WireFormat.getBoolSizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = BooleanArray(arraySize)
|
val newArray = BooleanArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -869,7 +869,7 @@ class MessageRepeatedVarints private constructor (var int: IntArray, var long: L
|
|||||||
readSize += WireFormat.getUInt32SizeNoTag(tmp)
|
readSize += WireFormat.getUInt32SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = IntArray(arraySize)
|
val newArray = IntArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -898,7 +898,7 @@ class MessageRepeatedVarints private constructor (var int: IntArray, var long: L
|
|||||||
readSize += WireFormat.getUInt64SizeNoTag(tmp)
|
readSize += WireFormat.getUInt64SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = LongArray(arraySize)
|
val newArray = LongArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ class MessageRepeatedZigZag private constructor (var int: IntArray, var long: Lo
|
|||||||
readSize += WireFormat.getSInt32SizeNoTag(tmp)
|
readSize += WireFormat.getSInt32SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = IntArray(arraySize)
|
val newArray = IntArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -288,7 +288,7 @@ class MessageRepeatedZigZag private constructor (var int: IntArray, var long: Lo
|
|||||||
readSize += WireFormat.getSInt64SizeNoTag(tmp)
|
readSize += WireFormat.getSInt64SizeNoTag(tmp)
|
||||||
}
|
}
|
||||||
} while (false)
|
} while (false)
|
||||||
var newArray = LongArray(arraySize)
|
val newArray = LongArray(arraySize)
|
||||||
input.reset()
|
input.reset()
|
||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ class TagOrder private constructor (var sint: Int, var int: Int, var slong_array
|
|||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
while(readSize < expectedByteSize) {
|
while(readSize < expectedByteSize) {
|
||||||
var tmp = LongArray(1)
|
val tmp = LongArray(1)
|
||||||
tmp[0] = input.readSInt64NoTag()
|
tmp[0] = input.readSInt64NoTag()
|
||||||
newArray = newArray.plus(tmp)
|
newArray = newArray.plus(tmp)
|
||||||
readSize += WireFormat.getSInt64SizeNoTag(tmp[0])
|
readSize += WireFormat.getSInt64SizeNoTag(tmp[0])
|
||||||
@@ -623,7 +623,7 @@ class TagOrderShuffled private constructor (var sint: Int, var int: Int, var slo
|
|||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
while(readSize < expectedByteSize) {
|
while(readSize < expectedByteSize) {
|
||||||
var tmp = LongArray(1)
|
val tmp = LongArray(1)
|
||||||
tmp[0] = input.readSInt64NoTag()
|
tmp[0] = input.readSInt64NoTag()
|
||||||
newArray = newArray.plus(tmp)
|
newArray = newArray.plus(tmp)
|
||||||
readSize += WireFormat.getSInt64SizeNoTag(tmp[0])
|
readSize += WireFormat.getSInt64SizeNoTag(tmp[0])
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ class RouteRequest private constructor(var distances: IntArray, var angles: IntA
|
|||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
while (readSize < expectedByteSize) {
|
while (readSize < expectedByteSize) {
|
||||||
var tmp = IntArray(1)
|
val tmp = IntArray(1)
|
||||||
tmp[0] = input.readInt32NoTag()
|
tmp[0] = input.readInt32NoTag()
|
||||||
newArray = newArray.plus(tmp)
|
newArray = newArray.plus(tmp)
|
||||||
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
||||||
@@ -414,7 +414,7 @@ class RouteRequest private constructor(var distances: IntArray, var angles: IntA
|
|||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
while (readSize < expectedByteSize) {
|
while (readSize < expectedByteSize) {
|
||||||
var tmp = IntArray(1)
|
val tmp = IntArray(1)
|
||||||
tmp[0] = input.readInt32NoTag()
|
tmp[0] = input.readInt32NoTag()
|
||||||
newArray = newArray.plus(tmp)
|
newArray = newArray.plus(tmp)
|
||||||
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ class RouteRequest private constructor (var distances: IntArray, var angles: Int
|
|||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
while(readSize < expectedByteSize) {
|
while(readSize < expectedByteSize) {
|
||||||
var tmp = IntArray(1)
|
val tmp = IntArray(1)
|
||||||
tmp[0] = input.readInt32NoTag()
|
tmp[0] = input.readInt32NoTag()
|
||||||
newArray = newArray.plus(tmp)
|
newArray = newArray.plus(tmp)
|
||||||
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
||||||
@@ -271,7 +271,7 @@ class RouteRequest private constructor (var distances: IntArray, var angles: Int
|
|||||||
do {
|
do {
|
||||||
var i = 0
|
var i = 0
|
||||||
while(readSize < expectedByteSize) {
|
while(readSize < expectedByteSize) {
|
||||||
var tmp = IntArray(1)
|
val tmp = IntArray(1)
|
||||||
tmp[0] = input.readInt32NoTag()
|
tmp[0] = input.readInt32NoTag()
|
||||||
newArray = newArray.plus(tmp)
|
newArray = newArray.plus(tmp)
|
||||||
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user