mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-02 12:50:55 +00:00
common: unused marker for marking values as unused intentionally
This commit is contained in:
parent
4ae1d19012
commit
87623505c0
9
common/src/main/kotlin/gay/pizza/pork/common/Globals.kt
Normal file
9
common/src/main/kotlin/gay/pizza/pork/common/Globals.kt
Normal file
@ -0,0 +1,9 @@
|
||||
package gay.pizza.pork.common
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "UnusedReceiverParameter", "unused")
|
||||
inline fun Any?.markIsUnused() {}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "unused")
|
||||
inline fun unused(value: Any?) {
|
||||
value.markIsUnused()
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package gay.pizza.pork.evaluator
|
||||
|
||||
import gay.pizza.pork.ast.ArgumentSpec
|
||||
import gay.pizza.pork.common.unused
|
||||
|
||||
class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
||||
private val functions = mutableMapOf(
|
||||
@ -16,18 +17,21 @@ class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
||||
}
|
||||
|
||||
private fun printValues(arguments: ArgumentList, stack: CallStack): Any {
|
||||
unused(stack)
|
||||
if (quiet || arguments.isEmpty()) return None
|
||||
print(arguments.joinToString(" "))
|
||||
return None
|
||||
}
|
||||
|
||||
private fun printLine(arguments: ArgumentList, stack: CallStack): Any {
|
||||
unused(stack)
|
||||
if (quiet) return None
|
||||
println(arguments.joinToString(" "))
|
||||
return None
|
||||
}
|
||||
|
||||
private fun setInList(arguments: ArgumentList, stack: CallStack): Any {
|
||||
unused(stack)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val list = arguments[0] as MutableList<Any>
|
||||
val value = arguments[2]
|
||||
@ -36,6 +40,7 @@ class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
||||
}
|
||||
|
||||
private fun listInitWith(arguments: ArgumentList, stack: CallStack): Any {
|
||||
unused(stack)
|
||||
val size = (arguments[0] as Number).toInt()
|
||||
return MutableList(size) { arguments[1] }
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":common"))
|
||||
implementation(project(":parser"))
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.psi.util.childrenOfType
|
||||
import com.intellij.util.PlatformIcons
|
||||
import gay.pizza.pork.ast.NodeType
|
||||
import gay.pizza.pork.common.unused
|
||||
import gay.pizza.pork.idea.PorkElementTypes
|
||||
import gay.pizza.pork.idea.PorkLanguage
|
||||
import gay.pizza.pork.idea.psi.gen.*
|
||||
@ -44,6 +45,7 @@ object PorkElementHelpers {
|
||||
}
|
||||
|
||||
fun referenceOfElement(element: PorkElement, type: NodeType): PsiReference? {
|
||||
unused(type)
|
||||
val textRangeOfSymbolInElement = element.childrenOfType<SymbolElement>().firstOrNull()?.textRangeInParent ?: return null
|
||||
return PorkIdentifierReference(element, textRangeOfSymbolInElement)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user