translator: logging
This commit is contained in:
@@ -17,13 +17,13 @@ object Voyager {
|
||||
}
|
||||
|
||||
private fun rotate(degree: Int) {
|
||||
val time = (degree / VELOCITY_DRIVE).toInt()
|
||||
val time = (degree.toDouble() / VELOCITY_DRIVE).toInt()
|
||||
Engine.left()
|
||||
Time.wait(time)
|
||||
}
|
||||
|
||||
private fun drive(direction: RouteType, distance: Int) {
|
||||
val time = (distance / VELOCITY_DRIVE).toInt()
|
||||
val time = (distance.toDouble() / VELOCITY_DRIVE).toInt()
|
||||
Engine.drive(direction.id)
|
||||
Time.wait(time)
|
||||
}
|
||||
|
||||
@@ -21,12 +21,10 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||
import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberType
|
||||
import org.kotlinnative.translator.llvm.*
|
||||
import org.kotlinnative.translator.llvm.types.*
|
||||
import java.rmi.UnexpectedException
|
||||
import java.util.*
|
||||
import javax.lang.model.type.ReferenceType
|
||||
import kotlin.comparisons.compareBy
|
||||
|
||||
|
||||
@@ -787,7 +785,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
codeBuilder.storeVariable(firstOp, resultOp)
|
||||
return LLVMExpression(resultOp.type, "load ${firstOp.getType()} $firstOp, align ${firstOp.type!!.align}")
|
||||
}
|
||||
else -> throw UnsupportedOperationException("Unknown binary operator")
|
||||
else -> throw UnsupportedOperationException("Unknown binary operator: $operator(${firstNativeOp.type}, ${secondNativeOp.type})")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class FunctionCodegen(state: TranslationState,
|
||||
|
||||
actualArgs.addAll(args)
|
||||
|
||||
codeBuilder.addLLVMCode(LLVMFunctionDescriptor(fullName, actualArgs, actualReturnType, external, state.arm))
|
||||
codeBuilder.addLLVMCode(LLVMFunctionDescriptor(fullName, actualArgs, actualReturnType, external))
|
||||
}
|
||||
|
||||
private fun generateLoadArguments() {
|
||||
|
||||
@@ -153,7 +153,7 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
argFields.addAll(secondaryConstructorArguments)
|
||||
val currentConstructorIndex = LLVMType.mangleFunctionArguments(secondaryConstructorArguments)
|
||||
constructorFields.put(currentConstructorIndex, argFields)
|
||||
codeBuilder.addLLVMCode(LLVMFunctionDescriptor(fullName + currentConstructorIndex, argFields, LLVMVoidType(), arm = state.arm))
|
||||
codeBuilder.addLLVMCode(LLVMFunctionDescriptor(fullName + currentConstructorIndex, argFields, LLVMVoidType()))
|
||||
|
||||
codeBuilder.addStartExpression()
|
||||
|
||||
@@ -180,7 +180,7 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
argFields.add(classVal)
|
||||
argFields.addAll(constructorFields[primaryConstructorIndex]!!)
|
||||
|
||||
codeBuilder.addLLVMCode(LLVMFunctionDescriptor(fullName + primaryConstructorIndex, argFields, LLVMVoidType(), arm = state.arm))
|
||||
codeBuilder.addLLVMCode(LLVMFunctionDescriptor(fullName + primaryConstructorIndex, argFields, LLVMVoidType()))
|
||||
|
||||
codeBuilder.addStartExpression()
|
||||
generateLoadArguments(classVal)
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.kotlinnative.translator.TranslationState
|
||||
import org.kotlinnative.translator.llvm.types.*
|
||||
|
||||
|
||||
fun LLVMFunctionDescriptor(name: String, argTypes: List<LLVMVariable>?, returnType: LLVMType, declare: Boolean = false, arm: Boolean = false) =
|
||||
fun LLVMFunctionDescriptor(name: String, argTypes: List<LLVMVariable>?, returnType: LLVMType, declare: Boolean = false) =
|
||||
"${if (declare) "declare" else "define weak"} $returnType @$name(${
|
||||
argTypes?.mapIndexed { i: Int, s: LLVMVariable ->
|
||||
"${s.getType()} ${if (s.type is LLVMReferenceType && !(s.type as LLVMReferenceType).byRef) "byval" else ""} %${s.label}"
|
||||
|
||||
Reference in New Issue
Block a user