This is an automated email from the git hooks/post-receive script.

mehdi pushed a commit to branch master
in repository js-of-ocaml.

commit 58dcce3ebe3d555c752093374fdc9d29f3b8bc69
Author: Mehdi Dogguy <me...@debian.org>
Date:   Sun Oct 18 09:52:06 2015 +0200

    Imported Upstream version 2.4.1
---
 CHANGES                      |  8 ++++++++
 Makefile                     |  4 ++--
 Makefile.toplevel            |  4 ++--
 README.md                    |  1 +
 VERSION                      |  2 +-
 compiler/compile.ml          |  2 ++
 compiler/generate.ml         |  2 --
 compiler/instr.ml            | 47 +++++++++++++++++++++++++-------------------
 compiler/instr.mli           | 10 +++++++---
 compiler/parse_bytecode.ml   |  4 ++++
 compiler/specialize.ml       | 18 +++++++++--------
 lib/xmlHttpRequest.ml        |  2 +-
 opam                         |  2 +-
 runtime/fs.js                | 12 +++++------
 runtime/graphics.js          |  6 ++++--
 runtime/io.js                | 22 ++++++++++-----------
 runtime/jslib_js_of_ocaml.js |  7 ++-----
 runtime/marshal.js           | 11 ++++++-----
 runtime/md5.js               |  8 ++++----
 runtime/mlString.js          | 46 ++++++++++++++++++++++---------------------
 runtime/stdlib.js            | 46 +++++++++++++++++++++++++------------------
 runtime/toplevel.js          |  4 ++--
 toplevel/Makefile            |  7 +++++--
 23 files changed, 157 insertions(+), 118 deletions(-)

diff --git a/CHANGES b/CHANGES
index aa2a57f..65dfe35 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+===== 2.4.1 (2014-08-28) =====
+
+ * BugFixes
+ ** Compiler: restore compatibility with ocaml 4.02
+ ** Runtime: fix caml_hash, Math.imul may give wrong results (#215)
+ ** Lib: Graphics_js, update text drawing baseline
+ ** Lib: Fix overuse of FormData in XmlHttpRequest (Tomohiro Matsuyama #214)
+
 ===== 2.4 (2014-08-08) =====
 
  * Features/Changes
diff --git a/Makefile b/Makefile
index 2227ec8..d3e3612 100644
--- a/Makefile
+++ b/Makefile
@@ -13,9 +13,9 @@ compiler:
        $(MAKE) -C compiler
 compiler_lib: compiler
        $(MAKE) -C compiler lib
-jsoo_tools:
+jsoo_tools: compiler_lib
        $(MAKE) -C jsoo_tools
-library:
+library: compiler_lib
        $(MAKE) -C lib
 ocamlbuild:
        $(MAKE) -C ocamlbuild
diff --git a/Makefile.toplevel b/Makefile.toplevel
index b157ef2..4ecdeb1 100644
--- a/Makefile.toplevel
+++ b/Makefile.toplevel
@@ -29,7 +29,7 @@ v-4.02.%:
        opam switch "4.02.$*"
        eval `opam config env`
        opam install $(BASE)
-       $(MAKE)
-       $(MAKE) toplevel
+       $(MAKE) NO_SYNTAXES=1
+       $(MAKE) NO_SYNTAXES=1 toplevel
        mkdir -p toplevel/4.02.$*/
        cp toplevel/*.cmis.js toplevel/toplevel.js toplevel/4.02.$*/
diff --git a/README.md b/README.md
index 2ea6dd7..47e283d 100644
--- a/README.md
+++ b/README.md
@@ -91,6 +91,7 @@ functions can yield results different from usual:
 ## Toplevel
   * [Ocaml 4.01.0](http://ocsigen.github.io/js_of_ocaml/#version=4.01.0)
   * [Ocaml 
4.01.0+BER](http://ocsigen.github.io/js_of_ocaml/#version=4.01.0+BER) : 
MetaOcaml
+  * [Ocaml 4.02.0](http://ocsigen.github.io/js_of_ocaml/#version=4.02.0+trunk)
 
 ## Contents of the distribution
 | Filename  | Description                                  |
diff --git a/VERSION b/VERSION
index 6b4950e..005119b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4
+2.4.1
diff --git a/compiler/compile.ml b/compiler/compile.ml
index 3b15c73..8d982cf 100644
--- a/compiler/compile.ml
+++ b/compiler/compile.ml
@@ -224,5 +224,7 @@ let _ =
     Format.eprintf "%s: Error: %s@." Sys.argv.(0) s;
     exit 1
   | exc ->
+    let backtrace = Printexc.get_backtrace () in
     Format.eprintf "%s: Error: %s@." Sys.argv.(0) (Printexc.to_string exc);
+    prerr_string backtrace;
     exit 1
diff --git a/compiler/generate.ml b/compiler/generate.ml
index 769f182..53a4b8f 100644
--- a/compiler/generate.ml
+++ b/compiler/generate.ml
@@ -791,8 +791,6 @@ let _ =
   register_un_prim "caml_js_to_bool" `Pure to_int;
   register_un_prim "caml_js_from_string" `Mutable
     (fun cx -> J.ECall (J.EDot (cx, "toString"), []));
-  register_un_prim "caml_js_to_string" `Mutable
-    (fun cx -> J.ENew (s_var "MlWrappedString", Some [cx]));
   register_tern_prim "caml_js_set"
     (fun cx cy cz -> J.EBin (J.Eq, J.EAccess (cx, cy), cz));
   register_bin_prim "caml_js_get" `Mutable
diff --git a/compiler/instr.ml b/compiler/instr.ml
index 641456a..ee238cc 100644
--- a/compiler/instr.ml
+++ b/compiler/instr.ml
@@ -19,7 +19,7 @@
  *)
 
 type t =
-    ACC0
+  | ACC0
   | ACC1
   | ACC2
   | ACC3
@@ -111,8 +111,6 @@ type t =
   | PUSHTRAP
   | POPTRAP
   | RAISE
-  | RERAISE
-  | RAISE_NOTRACE
   | CHECK_SIGNALS
   | C_CALL1
   | C_CALL2
@@ -165,6 +163,12 @@ type t =
   | GETPUBMET
   | GETDYNMET
   | STOP
+  | EVENT
+  | BREAK
+  | RERAISE
+  | RAISE_NOTRACE
+  | FIRST_UNIMPLEMENTED_OP
+
 
 type kind =
   | KNullary
@@ -177,12 +181,18 @@ type kind =
   | KClosurerec
   | KClosure
   | KStop of int
+  | K_will_not_happen
 
 type desc = { code : t; kind : kind; name : string; opcode : int }
 
 let ops,ops_rev =
   let ops_rev = Hashtbl.create 17 in
-  let block1 =
+  let if_v4 =
+    match Util.Version.v with
+      `V3    -> (fun _ default -> default)
+    | `V4_02 -> (fun k _ -> k)
+  in
+  let instrs =
     [| ACC0, KNullary, "ACC0";
        ACC1, KNullary, "ACC1";
        ACC2, KNullary, "ACC2";
@@ -274,12 +284,8 @@ let ops,ops_rev =
        BOOLNOT, KNullary, "BOOLNOT";
        PUSHTRAP, KCond_jump, "PUSHTRAP";
        POPTRAP, KNullary, "POPTRAP";
-       RAISE, KStop 0, "RAISE" |]
-  and block2 =
-    [| RERAISE, KStop 0, "RERAISE";
-       RAISE_NOTRACE, KStop 0, "RAISE_NOTRACE" |]
-  and block3 =
-    [| CHECK_SIGNALS, KNullary, "CHECK_SIGNALS";
+       RAISE, KStop 0, "RAISE";
+       CHECK_SIGNALS, KNullary, "CHECK_SIGNALS";
        C_CALL1, KUnary, "C_CALL1";
        C_CALL2, KUnary, "C_CALL2";
        C_CALL3, KUnary, "C_CALL3";
@@ -330,19 +336,18 @@ let ops,ops_rev =
        BUGEINT, KCmp_jump, "BUGEINT";
        GETPUBMET, KBinary, "GETPUBMET";
        GETDYNMET, KNullary, "GETDYNMET";
-       STOP, KStop 0, "STOP"|]
-  in
-  let instrs =
-    match Util.Version.v with
-      `V3    -> [block1; block3]
-    | `V4_02 -> [block1; block2; block3]
-  in
+       STOP, KStop 0, "STOP";
+       EVENT, K_will_not_happen, "EVENT";
+       BREAK, K_will_not_happen, "BREAK";
+       RERAISE, if_v4 (KStop 0) K_will_not_happen, "RERAISE";
+       RAISE_NOTRACE, if_v4 (KStop 0) K_will_not_happen, "RAISE_NOTRACE";
+       FIRST_UNIMPLEMENTED_OP, K_will_not_happen, "FIRST_UNIMPLEMENTED_OP"|] in
   let ops =
     Array.mapi
       (fun i (c, k, n) ->
          Hashtbl.add ops_rev c i;
-         {code = c; kind = k; name = n; opcode = i})
-      (Array.concat instrs)
+         {code = c; kind = k; name = n; opcode = i}
+      ) instrs
   in
   ops,ops_rev
 
@@ -391,7 +396,9 @@ exception Bad_instruction of int
 let get_instr code pc =
   let i = getu code pc in
   if i < 0 || i >= Array.length ops then raise (Bad_instruction i);
-  ops.(i)
+  let ins = ops.(i) in
+  if ins.kind = K_will_not_happen then raise (Bad_instruction i);
+  ins
 
 (****)
 
diff --git a/compiler/instr.mli b/compiler/instr.mli
index ee6eab2..7d7858a 100644
--- a/compiler/instr.mli
+++ b/compiler/instr.mli
@@ -19,7 +19,7 @@
  *)
 
 type t =
-    ACC0
+  | ACC0
   | ACC1
   | ACC2
   | ACC3
@@ -111,8 +111,6 @@ type t =
   | PUSHTRAP
   | POPTRAP
   | RAISE
-  | RERAISE
-  | RAISE_NOTRACE
   | CHECK_SIGNALS
   | C_CALL1
   | C_CALL2
@@ -165,6 +163,11 @@ type t =
   | GETPUBMET
   | GETDYNMET
   | STOP
+  | EVENT
+  | BREAK
+  | RERAISE
+  | RAISE_NOTRACE
+  | FIRST_UNIMPLEMENTED_OP
 
 type kind =
   | KNullary
@@ -177,6 +180,7 @@ type kind =
   | KClosurerec
   | KClosure
   | KStop of int
+  | K_will_not_happen
 
 type desc = { code : t; kind : kind; name : string; opcode : int }
 
diff --git a/compiler/parse_bytecode.ml b/compiler/parse_bytecode.ml
index 1075611..91c6190 100644
--- a/compiler/parse_bytecode.ml
+++ b/compiler/parse_bytecode.ml
@@ -73,6 +73,7 @@ end = struct
         scan blocks code (pc + 3) len
       | KStop n ->
         scan blocks code (pc + n + 1) len
+      | K_will_not_happen -> assert false
     end
     else blocks
 
@@ -1577,6 +1578,9 @@ and compile blocks code limit pc state instrs =
          Let (meths, Field (obj, 0)) :: instrs)
     | STOP ->
       (instrs, Stop, state)
+    | EVENT
+    | BREAK
+    | FIRST_UNIMPLEMENTED_OP -> assert false
   end
 
 (****)
diff --git a/compiler/specialize.ml b/compiler/specialize.ml
index f97ef69..8a48c78 100644
--- a/compiler/specialize.ml
+++ b/compiler/specialize.ml
@@ -21,22 +21,24 @@
 open Code
 open Flow
 
-let rec function_cardinality info x =
+let rec function_cardinality info x acc =
   get_approx info
     (fun x ->
        match info.info_defs.(Var.idx x) with
        | Expr (Closure (l, _)) ->
            Some (List.length l)
        | Expr (Apply (f, l, _)) ->
-           begin match function_cardinality info f with
+         if List.mem f acc
+         then None
+         else begin match function_cardinality info f (f::acc) with
              Some n ->
-               let diff = n - List.length l in
-               if diff > 0 then Some diff else None
+             let diff = n - List.length l in
+             if diff > 0 then Some diff else None
            | None ->
-               None
-           end
+             None
+         end
        | _ ->
-           None)
+         None)
     None
     (fun u v -> match u, v with Some n, Some m when n = m -> u | _ -> None)
     x
@@ -45,7 +47,7 @@ let specialize_instr info (acc,free_pc,extra) i =
   match i with
     | Let (x, Apply (f, l, _)) when Option.Optim.optcall () -> begin
       let n' = List.length l in
-      match function_cardinality info f with
+      match function_cardinality info f [] with
         | None -> i::acc,free_pc,extra
         | Some n when n = n' -> Let (x, Apply (f, l, true))::acc,free_pc,extra
         | Some n when n < n' ->
diff --git a/lib/xmlHttpRequest.ml b/lib/xmlHttpRequest.ml
index f62484b..14af2ea 100644
--- a/lib/xmlHttpRequest.ml
+++ b/lib/xmlHttpRequest.ml
@@ -171,7 +171,7 @@ let perform_raw_url
        (match post_args with
          | None -> None
          | Some post_args ->
-           let contents = Form.empty_form_contents () in
+           let contents = `Fields (ref []) in
            List.iter (fun (name, value) ->
               Form.append contents (name, value))
               post_args;
diff --git a/opam b/opam
index a7e658c..bfe01ac 100644
--- a/opam
+++ b/opam
@@ -21,5 +21,5 @@ depopts: ["deriving" "tyxml" "reactiveData" ]
 conflicts: [
   "deriving" {< "0.6"}
   "lwt"      {< "2.4"}
-  "tyxml"    {< "3.2"}
+  "tyxml"    {< "3.2.1"}
 ]
diff --git a/runtime/fs.js b/runtime/fs.js
index 7cf8d34..939bf1d 100644
--- a/runtime/fs.js
+++ b/runtime/fs.js
@@ -52,8 +52,8 @@ MlFile.prototype = {
 
 
 //Provides: caml_sys_getcwd
-//Requires: caml_current_dir, MlString
-function caml_sys_getcwd() { return new MlString(caml_current_dir); }
+//Requires: caml_current_dir, caml_new_string
+function caml_sys_getcwd() { return caml_new_string(caml_current_dir); }
 //Provides: caml_sys_chdir
 //Requires: caml_current_dir, caml_make_path
 //Requires: caml_sys_file_exists, caml_sys_is_directory,caml_raise_no_such_file
@@ -105,7 +105,7 @@ function caml_make_path (name) {
 
 //Provides: caml_fs_register
 //Requires: MlDir, MlFile, caml_root_dir, MlString, caml_make_path, 
caml_raise_sys_error
-//Requires: caml_invalid_argument
+//Requires: caml_invalid_argument, caml_new_string
 // content can be : MlDIr,MlFile,MlString,Array, string
 function caml_fs_register(name,content) {
   var path = caml_make_path(name);
@@ -124,7 +124,7 @@ function caml_fs_register(name,content) {
   else if(content instanceof MlFile) dir.mk(d,content);
   else if(content instanceof MlString) dir.mk(d,new 
MlFile(content.getArray()));
   else if(content instanceof Array) dir.mk(d,new MlFile(content));
-  else if(content.toString) dir.mk(d,new MlFile((new 
MlString(content.toString())).getArray()));
+  else if(content.toString) dir.mk(d,new 
MlFile((caml_new_string(content.toString())).getArray()));
   else caml_invalid_argument("caml_fs_register");
   return 0;
 }
@@ -202,7 +202,7 @@ function caml_fs_register_autoload(path,f){
 }
 
 //Provides: caml_sys_read_directory
-//Requires: MlString, MlDir
+//Requires: caml_new_string, MlDir
 //Requires: caml_fs_content, caml_make_path, caml_raise_not_a_dir
 function caml_sys_read_directory(name){
   var dir = caml_fs_content(caml_make_path(name));
@@ -212,7 +212,7 @@ function caml_sys_read_directory(name){
   var l = [0];
   var list = dir.list();
   for(var i=0;i<list.length;i++)
-    l.push(new MlString(list[i]));
+    l.push(caml_new_string(list[i]));
   return l;
 }
 
diff --git a/runtime/graphics.js b/runtime/graphics.js
index db75741..0b09541 100644
--- a/runtime/graphics.js
+++ b/runtime/graphics.js
@@ -21,12 +21,12 @@ var caml_gr_state;
 
 //Provides: caml_gr_state_get
 //Requires: caml_gr_state
-//Requires: caml_named_value, MlString
+//Requires: caml_named_value, caml_new_string
 function caml_gr_state_get() {
   if(caml_gr_state) {
     return caml_gr_state;
   }
-  throw [0,caml_named_value("Graphics.Graphic_failure"), new MlString("Not 
initialized")]
+  throw [0,caml_named_value("Graphics.Graphic_failure"), caml_new_string("Not 
initialized")]
 }
 //Provides: caml_gr_state_set
 //Requires: caml_gr_state,caml_gr_state_init
@@ -92,6 +92,8 @@ function caml_gr_state_init(){
   caml_gr_set_font(caml_gr_state.font);
   caml_gr_set_color(caml_gr_state.color);
   caml_gr_set_window_title(caml_gr_state.title);
+  //caml_gr_resize_window might reset some canvas' properties
+  caml_gr_state.context.textBaseline = 'bottom';
 }
 
 //Provides: caml_gr_state_create
diff --git a/runtime/io.js b/runtime/io.js
index 2155a8f..d141399 100644
--- a/runtime/io.js
+++ b/runtime/io.js
@@ -102,9 +102,9 @@ function caml_ml_out_channels_list () {
 
 //Provides: caml_ml_open_descriptor_out
 //Requires: js_print_stderr, js_print_stdout, caml_ml_out_channels, 
caml_global_data,caml_sys_open
-//Requires: caml_raise_sys_error,MlString
+//Requires: caml_raise_sys_error,caml_new_string
 function caml_std_output(chan,s){
-  var str = new MlString(s),slen = str.getLen();
+  var str = caml_new_string(s),slen = str.getLen();
   for(var i = 0;i<slen;i++){
     chan.data.array[chan.data.offset + i] = str.get(i);
   }
@@ -185,30 +185,30 @@ function caml_ml_set_channel_output(chan,f) {
 }
 
 //Provides: caml_ml_input
-//Requires: caml_blit_string, MlStringFromArray
+//Requires: caml_blit_string, caml_string_of_array
 function caml_ml_input (chan, s, i, l) {
   var l2 = chan.data.array.length - chan.data.offset;
   if (l2 < l) l = l2;
-  caml_blit_string(new MlStringFromArray(chan.data.array), chan.data.offset, 
s, i, l);
+  caml_blit_string(caml_string_of_array(chan.data.array), chan.data.offset, s, 
i, l);
   chan.data.offset += l;
   return l;
 }
 
 //Provides: caml_fs_file_content
-//Requires: MlStringFromArray, caml_fs_content, caml_make_path, MlFile
+//Requires: caml_string_of_array, caml_fs_content, caml_make_path, MlFile
 //Requires: caml_raise_not_found
 function caml_fs_file_content(name) {
   var path = caml_make_path(name);
   var f = caml_fs_content(path);
   if(f instanceof MlFile)
-    return new MlStringFromArray(f.content());
+    return caml_string_of_array(f.content());
   caml_raise_not_found();
 }
 
 //Provides: caml_input_value
-//Requires: caml_marshal_data_size, caml_input_value_from_string, 
MlStringFromArray
+//Requires: caml_marshal_data_size, caml_input_value_from_string, 
caml_string_of_array
 function caml_input_value (chan) {
-  var str = new MlStringFromArray(chan.data.array);
+  var str = caml_string_of_array(chan.data.array);
   var _len = caml_marshal_data_size (str, chan.data.offset);
   var res = caml_input_value_from_string(str, chan.data.offset);
   chan.data.offset = str.offset;
@@ -290,7 +290,7 @@ function caml_ml_flush (oc) {
 
 //Provides: caml_ml_output
 //Requires: caml_ml_flush
-//Requires: MlString, caml_create_string, caml_blit_string, 
caml_raise_sys_error
+//Requires: caml_create_string, caml_blit_string, caml_raise_sys_error
 function caml_ml_output (oc,buffer,offset,len) {
     if(! oc.opened) caml_raise_sys_error("Cannot output to a closed channel");
     var string;
@@ -353,10 +353,10 @@ function caml_ml_pos_out_64(chan) {
 
 //Provides: caml_ml_output_int
 //Requires: caml_ml_output
-//Requires: MlStringFromArray
+//Requires: caml_string_of_array
 function caml_ml_output_int (oc,i) {
   var arr = [(i>>24) & 0xFF,(i>>16) & 0xFF,(i>>8) & 0xFF,i & 0xFF ];
-  var s = new MlStringFromArray(arr);
+  var s = caml_string_of_array(arr);
   caml_ml_output(oc,s,0,4);
   return 0
 }
diff --git a/runtime/jslib_js_of_ocaml.js b/runtime/jslib_js_of_ocaml.js
index 913f1da..c7e7f89 100644
--- a/runtime/jslib_js_of_ocaml.js
+++ b/runtime/jslib_js_of_ocaml.js
@@ -30,9 +30,6 @@ function caml_js_to_float(x) { return x; }
 //Provides: caml_js_from_string mutable
 //Requires: MlString
 function caml_js_from_string(s) { return s.toString(); }
-//Provides: caml_js_to_string const
-//Requires: MlWrappedString
-function caml_js_to_string(s) { return new MlWrappedString(s); }
 //Provides: caml_js_from_array mutable
 function caml_js_from_array(a) { return a.slice(1); }
 //Provides: caml_js_to_array mutable
@@ -99,8 +96,8 @@ function caml_js_equals (x, y) { return +(x == y); }
 //Requires: MlString
 function caml_js_from_byte_string (s) {return s.getFullBytes();}
 //Provides: caml_js_to_byte_string const
-//Requires: MlString
-function caml_js_to_byte_string (s) {return new MlString (s);}
+//Requires: caml_new_string
+function caml_js_to_byte_string (s) {return caml_new_string (s);}
 
 //Provides: caml_js_eval_string
 //Requires: MlString
diff --git a/runtime/marshal.js b/runtime/marshal.js
index 67a4e8e..6cbb496 100644
--- a/runtime/marshal.js
+++ b/runtime/marshal.js
@@ -33,7 +33,8 @@ var caml_marshal_constants = {
 }
 
 //Provides: caml_input_value_from_string mutable
-//Requires: caml_failwith, MlStringFromArray, MlString, caml_marshal_constants
+//Requires: caml_failwith, caml_string_of_array, caml_new_string
+//Requires: caml_marshal_constants
 //Requires: caml_int64_float_of_bits, caml_int64_of_bytes
 var caml_input_value_from_string = function (){
   function ArrayReader (a, i) { this.a = a; this.i = i; }
@@ -63,7 +64,7 @@ var caml_input_value_from_string = function (){
     readstr:function (len) {
       var i = this.i;
       this.i = i + len;
-      return new MlStringFromArray(this.a.slice(i, i + len));
+      return caml_string_of_array(this.a.slice(i, i + len));
     }
   }
   function StringReader (s, i) { this.s = s; this.i = i; }
@@ -95,7 +96,7 @@ var caml_input_value_from_string = function (){
     readstr:function (len) {
       var i = this.i;
       this.i = i + len;
-      return new MlString(this.s.substring(i, i + len));
+      return caml_new_string(this.s.substring(i, i + len));
     }
   }
   function caml_float_of_bytes (a) {
@@ -396,10 +397,10 @@ var caml_output_val = function (){
 } ();
 
 //Provides: caml_output_value_to_string mutable
-//Requires: caml_output_val, MlStringFromArray
+//Requires: caml_output_val, caml_string_of_array
 function caml_output_value_to_string (v, _fl) {
   /* ignores flags... */
-  return new MlStringFromArray (caml_output_val (v));
+  return caml_string_of_array (caml_output_val (v));
 }
 
 //Provides: caml_output_value_to_buffer
diff --git a/runtime/md5.js b/runtime/md5.js
index e40bc74..e73fed4 100644
--- a/runtime/md5.js
+++ b/runtime/md5.js
@@ -19,16 +19,16 @@
 
 
 //Provides: caml_md5_chan
-//Requires: caml_md5_string, MlStringFromArray
+//Requires: caml_md5_string, caml_string_of_array
 function caml_md5_chan(chan,len){
   if(len<0){
     len=chan.data.array.length - chan.data.offset;
   }
-  return caml_md5_string(new 
MlStringFromArray(chan.data.array),chan.data.offset,len);
+  return 
caml_md5_string(caml_string_of_array(chan.data.array),chan.data.offset,len);
 }
 
 //Provides: caml_md5_string
-//Requires: MlString, MlStringFromArray
+//Requires: caml_string_of_array
 var caml_md5_string =
 function () {
   function add (x, y) { return (x + y) | 0; }
@@ -160,6 +160,6 @@ function () {
       }
       for (; i < len; i++) buf[i>>2] |= b.charCodeAt(i + ofs) << (8 * (i & 3));
     }
-    return new MlStringFromArray(md5(buf, len));
+    return caml_string_of_array(md5(buf, len));
   }
 } ();
diff --git a/runtime/mlString.js b/runtime/mlString.js
index ddbae66..1dcf1c5 100644
--- a/runtime/mlString.js
+++ b/runtime/mlString.js
@@ -41,9 +41,13 @@ function caml_str_repeat(n, s) {
 //Provides: MlString
 //Requires: caml_raise_with_arg, js_print_stderr, caml_global_data, 
caml_str_repeat
 function MlString(param) {
-  if (param != null) {
+  this.string = this.array = null;
+  if (param !== undefined) {
     this.bytes = this.fullBytes = param;
     this.last = this.len = param.length;
+  } else {
+    this.bytes = this.fullBytes = null;
+    this.len = null; this.last = 0;
   }
 }
 //This is here to avoid circular deps
@@ -52,16 +56,16 @@ function mlstring_bound_error () {
 }
 MlString.prototype = {
   // JS string : Utf16
-  string:null,
+  //     string:null,
   // byte string
-  bytes:null,
-  fullBytes:null,
+  //     bytes:null,
+  //     fullBytes:null,
   // byte array
-  array:null,
+  //     array:null,
   // length
-  len:null,
+  //     len:null,
   // last initialized byte
-  last:0,
+  //     last:0,
 
   toJsString:function() {
     // assumes this.string == null
@@ -242,30 +246,28 @@ MlString.prototype = {
 
 // Conversion Javascript -> Caml
 
-//Provides: MlWrappedString
+//Provides: caml_js_to_string const
 //Requires: MlString
-function MlWrappedString (s) { this.string = s; }
-MlWrappedString.prototype = new MlString();
-
-// Uninitialized Caml string
-//Provides: MlMakeString
-//Requires: MlString
-function MlMakeString (l) { this.bytes = ""; this.len = l; }
-MlMakeString.prototype = new MlString ();
+function caml_js_to_string(s) {
+  var x = new MlString (); x.string = s; return x;
+}
 
 // Caml string initialized form an array of bytes
-//Provides: MlStringFromArray
+//Provides: caml_string_of_array
 //Requires: MlString
-function MlStringFromArray (a) {
-  var len = a.length; this.array = a; this.len = this.last = len;
+function caml_string_of_array (a) {
+  var s = new MlString ();
+  var len = a.length; s.array = a; s.len = s.last = len;
+  return s;
 }
-MlStringFromArray.prototype = new MlString ();
 
 //Provides: caml_create_string const
-//Requires: MlMakeString,caml_invalid_argument
+//Requires: MlString,caml_invalid_argument
 function caml_create_string(len) {
   if (len < 0) caml_invalid_argument("String.create");
-  return new MlMakeString(len);
+  var s = new MlString();
+  s.bytes = ""; s.len = len;
+  return s;
 }
 //Provides: caml_fill_string
 //Requires: MlString
diff --git a/runtime/stdlib.js b/runtime/stdlib.js
index 72f7628..658ff00 100644
--- a/runtime/stdlib.js
+++ b/runtime/stdlib.js
@@ -74,9 +74,9 @@ function caml_raise_constant (tag) { throw tag; }
 function caml_raise_with_arg (tag, arg) { throw [0, tag, arg]; }
 
 //Provides: caml_raise_with_string
-//Requires: caml_raise_with_arg,MlWrappedString
+//Requires: caml_raise_with_arg,caml_new_string
 function caml_raise_with_string (tag, msg) {
-  caml_raise_with_arg (tag, new MlWrappedString (msg));
+  caml_raise_with_arg (tag, caml_new_string (msg));
 }
 
 //Provides: caml_raise_sys_error
@@ -91,7 +91,7 @@ function caml_failwith (msg) {
   caml_raise_with_string(caml_global_data[3], msg);
 }
 //Provides: caml_wrap_exception
-//Requires: caml_global_data,MlWrappedString,caml_named_value
+//Requires: caml_global_data,caml_js_to_string,caml_named_value
 function caml_wrap_exception(e) {
   if(e instanceof Array) return e;
   //Stack_overflow: chrome, safari
@@ -110,7 +110,7 @@ function caml_wrap_exception(e) {
   if(e instanceof joo_global_object.Error)
     return [0,caml_named_value("jsError"),e];
   //fallback: wrapped in Failure
-  return [0,caml_global_data[3],new MlWrappedString (String(e))];
+  return [0,caml_global_data[3],caml_js_to_string (String(e))];
 }
 
 //Provides: caml_invalid_argument
@@ -457,7 +457,7 @@ function caml_parse_format (fmt) {
 }
 
 //Provides: caml_finish_formatting
-//Requires: MlWrappedString
+//Requires: caml_new_string
 function caml_finish_formatting(f, rawbuffer) {
   if (f.uppercase) rawbuffer = rawbuffer.toUpperCase();
   var len = rawbuffer.length;
@@ -482,13 +482,14 @@ function caml_finish_formatting(f, rawbuffer) {
   buffer += rawbuffer;
   if (f.justify == '-')
     for (var i = len; i < f.width; i++) buffer += ' ';
-  return new MlWrappedString (buffer);
+  return caml_new_string (buffer);
 }
 
 //Provides: caml_format_int const
-//Requires: caml_parse_format, caml_finish_formatting, 
MlWrappedString,caml_str_repeat
+//Requires: caml_parse_format, caml_finish_formatting, caml_str_repeat
+//Requires: caml_new_string
 function caml_format_int(fmt, i) {
-  if (fmt.toString() == "%d") return new MlWrappedString(""+i);
+  if (fmt.toString() == "%d") return caml_new_string(""+i);
   var f = caml_parse_format(fmt);
   if (i < 0) { if (f.signedconv) { f.sign = -1; i = -i; } else i >>>= 0; }
   var s = i.toString(f.base);
@@ -609,18 +610,18 @@ function () {
   var HASH_QUEUE_SIZE = 256;
   function ROTL32(x,n) { return ((x << n) | (x >>> (32-n))); }
   function MIX(h,d) {
-    d = caml_mul(d, 0xcc9e2d51);
+    d = caml_mul(d, 0xcc9e2d51|0);
     d = ROTL32(d, 15);
     d = caml_mul(d, 0x1b873593);
     h ^= d;
     h = ROTL32(h, 13);
-    return ((((h * 5)|0) + 0xe6546b64)|0);
+    return (((h + (h << 2))|0) + (0xe6546b64|0))|0;
   }
   function FINAL_MIX(h) {
     h ^= h >>> 16;
-    h = caml_mul (h, 0x85ebca6b);
+    h = caml_mul (h, 0x85ebca6b|0);
     h ^= h >>> 13;
-    h = caml_mul (h, 0xc2b2ae35);
+    h = caml_mul (h, 0xc2b2ae35|0);
     h ^= h >>> 16;
     return h;
   }
@@ -742,9 +743,9 @@ function () {
 var caml_initial_time = new Date() * 0.001;
 function caml_sys_time () { return new Date() * 0.001 - caml_initial_time; }
 //Provides: caml_sys_get_config const
-//Requires: MlWrappedString
+//Requires: caml_new_string
 function caml_sys_get_config () {
-  return [0, new MlWrappedString("Unix"), 32, 0];
+  return [0, caml_new_string("Unix"), 32, 0];
 }
 //Provides: caml_sys_random_seed mutable
 //The function needs to return an array since OCaml 4.0...
@@ -850,7 +851,7 @@ function caml_convert_raw_backtrace () { return 0; }
 function caml_get_current_callstack () { return 0; }
 //Provides: caml_sys_getenv
 //Requires: caml_raise_not_found
-//Requires: MlWrappedString
+//Requires: caml_js_to_string
 function caml_sys_getenv (name) {
   var g = joo_global_object;
   var n = name.toString();
@@ -858,7 +859,7 @@ function caml_sys_getenv (name) {
   if(g.process
      && g.process.env
      && g.process.env[n] != undefined)
-    return new MlWrappedString(g.process.env[n]);
+    return caml_js_to_string(g.process.env[n]);
   caml_raise_not_found ();
 }
 //Provides: caml_sys_exit
@@ -872,7 +873,7 @@ function caml_sys_exit (code) {
 }
 
 //Provides: caml_sys_get_argv const
-//Requires: MlWrappedString
+//Requires: caml_js_to_string
 function caml_sys_get_argv () {
   var g = joo_global_object;
   var main = "a.out";
@@ -886,10 +887,10 @@ function caml_sys_get_argv () {
     args = g.process.argv.slice(2);
   }
 
-  var p = new MlWrappedString(main);
+  var p = caml_js_to_string(main);
   var args2 = [0, p];
   for(var i = 0; i < args.length; i++)
-    args2.push(new MlWrappedString(args[i]));
+    args2.push(caml_js_to_string(args[i]));
   return [0, p, args2];
 }
 
@@ -906,3 +907,10 @@ function caml_set_oo_id (b) {
 
 //Provides: caml_install_signal_handler const
 function caml_install_signal_handler(){return 0}
+
+
+//Provides: caml_convert_raw_backtrace_slot
+//Requires: caml_failwith
+function caml_convert_raw_backtrace_slot(){
+  caml_failwith("caml_convert_raw_backtrace_slot");
+}
diff --git a/runtime/toplevel.js b/runtime/toplevel.js
index e36a709..b26fe76 100644
--- a/runtime/toplevel.js
+++ b/runtime/toplevel.js
@@ -54,8 +54,8 @@ function caml_reify_bytecode (code, _sz) {
 function caml_static_release_bytecode () { return 0; }
 
 //Provides: caml_static_alloc
-//Requires: MlMakeString
-function caml_static_alloc (len) { return new MlMakeString (len); }
+//Requires: caml_create_string
+function caml_static_alloc (len) { return caml_create_string (len); }
 
 //Provides: caml_static_free
 function caml_static_free () { return 0; }
diff --git a/toplevel/Makefile b/toplevel/Makefile
index f16eddc..2b77178 100644
--- a/toplevel/Makefile
+++ b/toplevel/Makefile
@@ -16,8 +16,11 @@ ifneq ($(HIGLO),)
 OPTCOMP_OPT+= -let higlo=true
 endif
 
-SYNTAXES= lwt.syntax js_of_ocaml.syntax js_of_ocaml.deriving.syntax 
deriving.syntax.std
-
+ifneq ($(NO_SYNTAXES),1)
+SYNTAXES= lwt.syntax \
+       js_of_ocaml.syntax \
+       js_of_ocaml.deriving.syntax deriving.syntax.std
+endif
 
 JSFILES= +weak.js +toplevel.js +graphics.js +nat.js
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-ocaml-maint/packages/js-of-ocaml.git

_______________________________________________
Pkg-ocaml-maint-commits mailing list
Pkg-ocaml-maint-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to