fixed some exception catching problems on wasm target
This commit is contained in:
1 parent
c6cfd52b01
commit
b6c6ef021a
9 files changed
+207
-4
No files matched your search
@@ -3663,7 +3663,11 @@ class CmdGetIndex(
|
||||
val target = frame.storedSlotObj(targetSlot)
|
||||
val index = frame.storedSlotObj(indexSlot)
|
||||
if (target is ObjList && target::class == ObjList::class && index is ObjInt) {
|
||||
frame.storeObjResult(dst, target.getObjAtFast(index.toInt()))
|
||||
val i = index.toInt()
|
||||
objListBoundsViolationMessageOrNull(target.sizeFast(), i)?.let {
|
||||
frame.ensureScope().raiseIndexOutOfBounds(it)
|
||||
}
|
||||
frame.storeObjResult(dst, target.getObjAtFast(i))
|
||||
return
|
||||
}
|
||||
val result = target.getAt(frame.ensureScope(), index)
|
||||
@@ -3682,7 +3686,11 @@ class CmdSetIndex(
|
||||
val index = frame.storedSlotObj(indexSlot)
|
||||
val value = frame.slotToObj(valueSlot)
|
||||
if (target is ObjList && target::class == ObjList::class && index is ObjInt) {
|
||||
target.setObjAtFast(index.toInt(), value)
|
||||
val i = index.toInt()
|
||||
objListBoundsViolationMessageOrNull(target.sizeFast(), i)?.let {
|
||||
frame.ensureScope().raiseIndexOutOfBounds(it)
|
||||
}
|
||||
target.setObjAtFast(i, value)
|
||||
return
|
||||
}
|
||||
target.putAt(frame.ensureScope(), index, value)
|
||||
@@ -3699,6 +3707,9 @@ class CmdGetIndexInt(
|
||||
val target = frame.storedSlotObj(targetSlot)
|
||||
val index = frame.getInt(indexSlot).toInt()
|
||||
if (target is ObjList && target::class == ObjList::class) {
|
||||
objListBoundsViolationMessageOrNull(target.sizeFast(), index)?.let {
|
||||
frame.ensureScope().raiseIndexOutOfBounds(it)
|
||||
}
|
||||
target.getIntAtFast(index)?.let {
|
||||
frame.setInt(dst, it)
|
||||
return
|
||||
@@ -3722,6 +3733,9 @@ class CmdSetIndexInt(
|
||||
val target = frame.storedSlotObj(targetSlot)
|
||||
val index = frame.getInt(indexSlot).toInt()
|
||||
if (target is ObjList && target::class == ObjList::class) {
|
||||
objListBoundsViolationMessageOrNull(target.sizeFast(), index)?.let {
|
||||
frame.ensureScope().raiseIndexOutOfBounds(it)
|
||||
}
|
||||
target.setIntAtFast(index, frame.getInt(valueSlot))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -171,7 +171,9 @@ open class ObjList(initialList: MutableList<Obj> = mutableListOf()) : Obj() {
|
||||
override suspend fun getAt(scope: Scope, index: Obj): Obj {
|
||||
return when (index) {
|
||||
is ObjInt -> {
|
||||
getObjAtFast(index.toInt())
|
||||
val i = index.toInt()
|
||||
objListBoundsViolationMessageOrNull(sizeFast(), i)?.let { scope.raiseIndexOutOfBounds(it) }
|
||||
getObjAtFast(i)
|
||||
}
|
||||
|
||||
is ObjRange -> {
|
||||
@@ -209,7 +211,9 @@ open class ObjList(initialList: MutableList<Obj> = mutableListOf()) : Obj() {
|
||||
}
|
||||
|
||||
open override suspend fun putAt(scope: Scope, index: Obj, newValue: Obj) {
|
||||
setObjAtFast(index.toInt(), newValue)
|
||||
val i = index.toInt()
|
||||
objListBoundsViolationMessageOrNull(sizeFast(), i)?.let { scope.raiseIndexOutOfBounds(it) }
|
||||
setObjAtFast(i, newValue)
|
||||
}
|
||||
|
||||
override suspend fun compareTo(scope: Scope, other: Obj): Int {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.sergeych.lyng.obj
|
||||
|
||||
internal expect fun objListBoundsViolationMessageOrNull(size: Int, index: Int): String?
|
||||
Reference in new issue
Block a user