mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-02 21:00:56 +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
|
package gay.pizza.pork.evaluator
|
||||||
|
|
||||||
import gay.pizza.pork.ast.ArgumentSpec
|
import gay.pizza.pork.ast.ArgumentSpec
|
||||||
|
import gay.pizza.pork.common.unused
|
||||||
|
|
||||||
class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
||||||
private val functions = mutableMapOf(
|
private val functions = mutableMapOf(
|
||||||
@ -16,18 +17,21 @@ class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun printValues(arguments: ArgumentList, stack: CallStack): Any {
|
private fun printValues(arguments: ArgumentList, stack: CallStack): Any {
|
||||||
|
unused(stack)
|
||||||
if (quiet || arguments.isEmpty()) return None
|
if (quiet || arguments.isEmpty()) return None
|
||||||
print(arguments.joinToString(" "))
|
print(arguments.joinToString(" "))
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun printLine(arguments: ArgumentList, stack: CallStack): Any {
|
private fun printLine(arguments: ArgumentList, stack: CallStack): Any {
|
||||||
|
unused(stack)
|
||||||
if (quiet) return None
|
if (quiet) return None
|
||||||
println(arguments.joinToString(" "))
|
println(arguments.joinToString(" "))
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setInList(arguments: ArgumentList, stack: CallStack): Any {
|
private fun setInList(arguments: ArgumentList, stack: CallStack): Any {
|
||||||
|
unused(stack)
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val list = arguments[0] as MutableList<Any>
|
val list = arguments[0] as MutableList<Any>
|
||||||
val value = arguments[2]
|
val value = arguments[2]
|
||||||
@ -36,6 +40,7 @@ class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun listInitWith(arguments: ArgumentList, stack: CallStack): Any {
|
private fun listInitWith(arguments: ArgumentList, stack: CallStack): Any {
|
||||||
|
unused(stack)
|
||||||
val size = (arguments[0] as Number).toInt()
|
val size = (arguments[0] as Number).toInt()
|
||||||
return MutableList(size) { arguments[1] }
|
return MutableList(size) { arguments[1] }
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(project(":common"))
|
||||||
implementation(project(":parser"))
|
implementation(project(":parser"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
|||||||
import com.intellij.psi.util.childrenOfType
|
import com.intellij.psi.util.childrenOfType
|
||||||
import com.intellij.util.PlatformIcons
|
import com.intellij.util.PlatformIcons
|
||||||
import gay.pizza.pork.ast.NodeType
|
import gay.pizza.pork.ast.NodeType
|
||||||
|
import gay.pizza.pork.common.unused
|
||||||
import gay.pizza.pork.idea.PorkElementTypes
|
import gay.pizza.pork.idea.PorkElementTypes
|
||||||
import gay.pizza.pork.idea.PorkLanguage
|
import gay.pizza.pork.idea.PorkLanguage
|
||||||
import gay.pizza.pork.idea.psi.gen.*
|
import gay.pizza.pork.idea.psi.gen.*
|
||||||
@ -44,6 +45,7 @@ object PorkElementHelpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun referenceOfElement(element: PorkElement, type: NodeType): PsiReference? {
|
fun referenceOfElement(element: PorkElement, type: NodeType): PsiReference? {
|
||||||
|
unused(type)
|
||||||
val textRangeOfSymbolInElement = element.childrenOfType<SymbolElement>().firstOrNull()?.textRangeInParent ?: return null
|
val textRangeOfSymbolInElement = element.childrenOfType<SymbolElement>().firstOrNull()?.textRangeInParent ?: return null
|
||||||
return PorkIdentifierReference(element, textRangeOfSymbolInElement)
|
return PorkIdentifierReference(element, textRangeOfSymbolInElement)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user