Skip to content

Commit

Permalink
bring back table.fill
Browse files Browse the repository at this point in the history
  • Loading branch information
zapashcanon committed Sep 16, 2023
1 parent 6bc1b94 commit d8c0dc3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/interpret_functor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,18 +1067,14 @@ module Make (P : Interpret_functor_intf.P) :
let new_element, stack = Stack.pop_as_ref stack in
Table.grow t new_size new_element;
Stack.push_i32 stack size
| Table_fill _indice ->
(* TODO *)
| Table_fill indice ->
let/* t = Env.get_table env indice in
let len, stack = Stack.pop_i32 stack in
let x, stack = Stack.pop_as_ref stack in
let pos, stack = Stack.pop_i32 stack in
(* TODO: out of bounds check *)
Table.fill t pos len x;
st stack
(* let* t = Env.get_table env indice in *)
(* let len, stack = Stack.pop_i32_to_int stack in *)
(* let x, stack = Stack.pop_as_ref stack in *)
(* let pos, stack = Stack.pop_i32_to_int stack in *)
(* begin *)
(* try Array.fill t.data pos len x *)
(* with Invalid_argument _ -> trap "out of bounds table access" *)
(* end; *)
(* st stack *)
| Table_copy (_ti_dst, _ti_src) ->
(* TODO *)
st stack
Expand Down
2 changes: 2 additions & 0 deletions src/interpret_functor_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ module type P = sig
val max_size : t -> int option

val grow : t -> int32 -> Value.ref_value -> unit

val fill : t -> int32 -> int32 -> Value.ref_value -> unit
end

module Memory : sig
Expand Down
2 changes: 2 additions & 0 deletions src/sym_state.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ module P = struct
let max_size _t = assert false

let grow _t _new_size _x = assert false

let fill _t _pos _len _x = assert false
end

module Elem = struct
Expand Down
5 changes: 5 additions & 0 deletions src/table.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ let grow t new_size x =
let new_table = Array.make new_size x in
Array.blit t.data 0 new_table 0 (Array.length t.data);
update t new_table

let fill t pos len x =
let pos = Int32.to_int pos in
let len = Int32.to_int len in
Array.fill t.data pos len x
2 changes: 2 additions & 0 deletions src/table.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ val init : ?label:string -> Simplified.table_type -> t
val max_size : t -> int option

val grow : t -> int32 -> Value.ref_value -> unit

val fill : t -> int32 -> int32 -> Value.ref_value -> unit

0 comments on commit d8c0dc3

Please sign in to comment.