From 8cd6ddb98c12b6aba002781158180ffb68aba02f Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Thu, 23 Nov 2017 14:28:21 +0100 Subject: Abstract further the type of VM bytecode compilation. This reduces the possibility to wreak havoc while making the API nicer. --- kernel/cemitcodes.ml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'kernel/cemitcodes.ml') diff --git a/kernel/cemitcodes.ml b/kernel/cemitcodes.ml index eeea19c12..bc6140ef4 100644 --- a/kernel/cemitcodes.ml +++ b/kernel/cemitcodes.ml @@ -22,6 +22,7 @@ type reloc_info = | Reloc_getglobal of Names.Constant.t type patch = reloc_info * int +type patches = patch list let patch_char4 buff pos c1 c2 c3 c4 = Bytes.unsafe_set buff pos c1; @@ -54,6 +55,12 @@ let patch_int buff patches = *) Bytes.unsafe_to_string buff +let patch buff pl f = + let map (r, pos) = (pos, f r) in + let patches = CList.map_left map pl in + let buff = patch_int buff patches in + buff + (* Buffering of bytecode *) let out_buffer = ref(Bytes.create 1024) -- cgit v1.2.3