From 4f9a2c7a2d8464b04cc08075a7762c6d457090df Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Wed, 22 May 2024 14:04:36 +0200 Subject: WIP --- src/op/variable_access/get_local.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/op/variable_access/get_local.c') diff --git a/src/op/variable_access/get_local.c b/src/op/variable_access/get_local.c index 745a2e7..7c80450 100644 --- a/src/op/variable_access/get_local.c +++ b/src/op/variable_access/get_local.c @@ -51,22 +51,17 @@ static int get_f64(struct nw_interp *const i, const void *const data, static int get_local(const varuint32 local_index, struct nw_interp *const i) { - struct nw_frame *fr; + struct nw_locals *l; varuint32 idx; - for (idx = local_index, fr = i->fp; fr; fr = fr->next) - if (idx < fr->n_locals) - break; - - if (!fr) + if (locals_get(local_index, i, &l, &idx)) { - LOG("%s: cannot access local variable %lu\n", __func__, - (unsigned long)local_index); - i->exception = "local variable index out of bounds"; + LOG("%s: locals_get failed\n", __func__); return -1; } - static int (*const get[])(struct nw_interp *, const void *, varuint32) = + static int (*const get[])(struct nw_interp *, const void *, + varuint32) = { [VALUE_TYPE_I32] = get_i32, [VALUE_TYPE_I64] = get_i64, @@ -74,9 +69,9 @@ static int get_local(const varuint32 local_index, struct nw_interp *const i) [VALUE_TYPE_F64] = get_f64, }; - if (get[fr->local_type](i, fr + 1, idx)) + if (get[l->type](i, l + 1, idx)) { - LOG("%s: get type %d failed\n", __func__, fr->local_type); + LOG("%s: get type %d failed\n", __func__, l->type); return -1; } -- cgit v1.2.3