[Wasm] Pull array range checks into single function

This commit is contained in:
Igor Laevsky
2022-03-31 15:32:30 +03:00
committed by teamcity
parent 6f448820f0
commit 2c9bfe901d
3 changed files with 22 additions and 18 deletions
@@ -25,6 +25,10 @@ internal fun throwNoBranchMatchedException(): Nothing {
throw NoWhenBranchMatchedException()
}
internal fun rangeCheck(index: Int, size: Int) {
if (index < 0 || index >= size) throw IndexOutOfBoundsException()
}
@PublishedApi
internal fun throwUninitializedPropertyAccessException(name: String): Nothing {
throw UninitializedPropertyAccessException("lateinit property $name has not been initialized")