All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.ir.interpreter.builtins.CompileTimeUtils.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/*
 * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

package org.jetbrains.kotlin.ir.interpreter.builtins

import org.jetbrains.kotlin.name.FqName

val compileTimeAnnotation = FqName("kotlin.CompileTimeCalculation")
val evaluateIntrinsicAnnotation = FqName("kotlin.EvaluateIntrinsic")
val contractsDslAnnotation = FqName("kotlin.internal.ContractsDsl")

data class CompileTimeFunction(val methodName: String, val args: List)

@Suppress("UNCHECKED_CAST")
fun  unaryOperation(
    methodName: String, receiverType: String, function: (T) -> Any?
): Pair> {
    return CompileTimeFunction(methodName, listOf(receiverType)) to function as Function1
}

@Suppress("UNCHECKED_CAST")
fun  binaryOperation(
    methodName: String, receiverType: String, parameterType: String, function: (T, E) -> Any?
): Pair> {
    return CompileTimeFunction(methodName, listOfNotNull(receiverType, parameterType)) to function as Function2
}

@Suppress("UNCHECKED_CAST")
fun  ternaryOperation(
    methodName: String, receiverType: String, firstParameterType: String, secondParameterType: String, function: (T, E, R) -> Any?
): Pair> {
    return CompileTimeFunction(
        methodName, listOfNotNull(receiverType, firstParameterType, secondParameterType)
    ) to function as Function3
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy