@@ -103,7 +103,7 @@ function jsoo_toplevel_init_reloc(f) {
103103//Requires: caml_callback
104104//Requires: caml_string_of_uint8_array, caml_ba_to_typed_array
105105//Requires: jsoo_toplevel_compile, caml_failwith
106- //Version: >= 5.2
106+ //Version: >= 5.3
107107function caml_reify_bytecode ( code , debug , _digest ) {
108108 if ( ! jsoo_toplevel_compile ) {
109109 caml_failwith ( "Toplevel not initialized (jsoo_toplevel_compile)" ) ;
@@ -137,6 +137,39 @@ function caml_reify_bytecode(code, debug, _digest) {
137137 return [ 0 , 0 , caml_callback ( jsoo_toplevel_compile , [ code , debug ] ) ] ;
138138}
139139
140+ //Provides: caml_reify_bytecode
141+ //Requires: caml_callback
142+ //Requires: caml_string_of_uint8_array, caml_uint8_array_of_bytes
143+ //Requires: caml_ba_to_typed_array
144+ //Requires: jsoo_toplevel_compile, caml_failwith
145+ //Version: >= 5.2, < 5.3
146+ //Compatible with OxCaml
147+ function caml_reify_bytecode ( code , debug , _digest ) {
148+ if ( ! jsoo_toplevel_compile ) {
149+ caml_failwith ( "Toplevel not initialized (jsoo_toplevel_compile)" ) ;
150+ }
151+ if ( code . data ) {
152+ //Version: >= 5.2
153+ code = caml_ba_to_typed_array ( code ) ;
154+ } else {
155+ // Oxcaml or version < 5.2
156+ var len = 0 ;
157+ var all = [ ] ;
158+ for ( var i = 1 ; i < code . length ; i ++ ) {
159+ var a = caml_uint8_array_of_bytes ( code [ i ] ) ;
160+ all . push ( a ) ;
161+ len += a . length ;
162+ }
163+ code = new Uint8Array ( len ) ;
164+ for ( var i = 0 , len = 0 ; i < all . length ; i ++ ) {
165+ code . set ( all [ i ] , len ) ;
166+ len += all [ i ] . length ;
167+ }
168+ }
169+ code = caml_string_of_uint8_array ( code ) ;
170+ return [ 0 , 0 , caml_callback ( jsoo_toplevel_compile , [ code , debug ] ) ] ;
171+ }
172+
140173//Provides: caml_static_release_bytecode
141174function caml_static_release_bytecode ( ) {
142175 return 0 ;
0 commit comments