Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Commit 63986ff

Browse files
committed
Move MemoryCopy and MemoryFill definitions
This uses the same as order as defined in syntax/ast.
1 parent 7c357ab commit 63986ff

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

interpreter/exec/eval.ml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,6 @@ let rec step (c : config) : config =
226226
with Memory.SizeOverflow | Memory.SizeLimit | Memory.OutOfMemory -> -1l
227227
in I32 result :: vs', []
228228

229-
| MemoryFill, I32 n :: I32 b :: I32 i :: vs' ->
230-
let mem = memory frame.inst (0l @@ e.at) in
231-
let addr = I64_convert.extend_i32_u i in
232-
(try Memory.fill mem addr (Int32.to_int b) n; vs', []
233-
with exn -> vs', [Trapping (memory_error e.at exn) @@ e.at])
234-
235-
| MemoryCopy, I32 n :: I32 s :: I32 d :: vs' ->
236-
let mem = memory frame.inst (0l @@ e.at) in
237-
let dst = I64_convert.extend_i32_u d in
238-
let src = I64_convert.extend_i32_u s in
239-
(try Memory.copy mem dst src n; vs', []
240-
with exn -> vs', [Trapping (memory_error e.at exn) @@ e.at])
241-
242229
| Const v, vs ->
243230
v.it :: vs, []
244231

@@ -262,6 +249,19 @@ let rec step (c : config) : config =
262249
(try Eval_numeric.eval_cvtop cvtop v :: vs', []
263250
with exn -> vs', [Trapping (numeric_error e.at exn) @@ e.at])
264251

252+
| MemoryCopy, I32 n :: I32 s :: I32 d :: vs' ->
253+
let mem = memory frame.inst (0l @@ e.at) in
254+
let dst = I64_convert.extend_i32_u d in
255+
let src = I64_convert.extend_i32_u s in
256+
(try Memory.copy mem dst src n; vs', []
257+
with exn -> vs', [Trapping (memory_error e.at exn) @@ e.at])
258+
259+
| MemoryFill, I32 n :: I32 b :: I32 i :: vs' ->
260+
let mem = memory frame.inst (0l @@ e.at) in
261+
let addr = I64_convert.extend_i32_u i in
262+
(try Memory.fill mem addr (Int32.to_int b) n; vs', []
263+
with exn -> vs', [Trapping (memory_error e.at exn) @@ e.at])
264+
265265
| _ ->
266266
let s1 = string_of_values (List.rev vs) in
267267
let s2 = string_of_value_types (List.map type_of (List.rev vs)) in

0 commit comments

Comments
 (0)