diff options
author | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2017-11-23 14:28:21 +0100 |
---|---|---|
committer | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2018-02-14 16:14:10 +0100 |
commit | 8cd6ddb98c12b6aba002781158180ffb68aba02f (patch) | |
tree | 82a3b98a604149a8ae984cb25986e915d9d155a5 /kernel/cemitcodes.ml | |
parent | 41893cb647fbdce87b40acd5763e837370d61ece (diff) |
Abstract further the type of VM bytecode compilation.
This reduces the possibility to wreak havoc while making the API nicer.
Diffstat (limited to 'kernel/cemitcodes.ml')
-rw-r--r-- | kernel/cemitcodes.ml | 7 |
1 files changed, 7 insertions, 0 deletions
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) |