diff --git a/.gitignore b/.gitignore index ae67372add..2012c61b28 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,5 @@ jscomp/bench/*.js .vscode *.jsx osc -jscomp/pre_load.js \ No newline at end of file +jscomp/pre_load.js +boot \ No newline at end of file diff --git a/README.md b/README.md index 2926a1edc1..65e4a8b3c8 100644 --- a/README.md +++ b/README.md @@ -247,8 +247,6 @@ Some known issues are listed as below: 1. Language features: - Recursive modules, Lazy modules, have not looked into it yet. - Int32 operations, currently, Int use Float operations, this should be fixed in the near future. diff --git a/jscomp/compiler.mllib b/jscomp/compiler.mllib index cbcd634df9..65c3e90b08 100644 --- a/jscomp/compiler.mllib +++ b/jscomp/compiler.mllib @@ -81,6 +81,8 @@ js_of_lam_tuple js_of_lam_string js_of_lam_block js_of_lam_array +js_of_lam_module +js_of_lam_exception js_implementation js_closure js_op @@ -93,3 +95,4 @@ js_number js_helper js_cmj_datasets js_main + diff --git a/jscomp/j.ml b/jscomp/j.ml index b85545228f..e1d48eec0e 100644 --- a/jscomp/j.ml +++ b/jscomp/j.ml @@ -47,13 +47,15 @@ and ident_info = Js_op.ident_info and exports = Js_op.exports +and tag_info = Js_op.tag_info + and required_modules = Js_op.required_modules (** object literal, if key is ident, in this case, it might be renamed by Google Closure optimizer, currently we always use quote *) -and property_name = string +and property_name = Js_op.property_name and ident = Ident.t @@ -101,8 +103,9 @@ and expression_desc = *) | Array_copy of expression (* shallow copy, like [x.slice] *) | Array_append of expression * expression (* For [caml_array_append]*) - | Tag_ml_obj of expression + (* | Tag_ml_obj of expression *) | String_append of expression * expression + | Int_of_boolean of expression (* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence [typeof] is an operator @@ -201,6 +204,28 @@ and expression_desc = which is better to leave it alone *) | Array of expression list * mutable_flag + | Caml_block of expression list * mutable_flag * expression * tag_info + + | Caml_uninitialized_obj of expression * expression + (* [tag] and [size] tailed for [Obj.new_block] *) + + (* For setter, it still return the value of expression, + we can not use + {[ + type 'a access = Get | Set of 'a + ]} + in another module, since it will break our code generator + [Caml_block_tag] can return [undefined], + you have to use [E.tag] in a safe way + *) + | Caml_block_tag of expression + | Caml_block_set_tag of expression * expression + | Caml_block_length of expression + | Caml_block_set_length of expression * expression + (* It will just fetch tag, to make it safe, when creating it, + we need apply "|0", we don't do it in the + last step since "|0" can potentially be optimized + *) | Number of number | Object of property_map diff --git a/jscomp/js_analyzer.ml b/jscomp/js_analyzer.ml index 6cfc9bf65c..5c9dab399f 100644 --- a/jscomp/js_analyzer.ml +++ b/jscomp/js_analyzer.ml @@ -79,6 +79,7 @@ let rec no_side_effect (x : J.expression) = | Fun _ -> true | Number _ -> true (* Can be refined later *) | Array (xs,_mutable_flag) + | Caml_block (xs, _mutable_flag, _, _) -> (** create [immutable] block, does not really mean that this opreation itself is [pure]. @@ -86,8 +87,44 @@ let rec no_side_effect (x : J.expression) = the block is mutable does not mean this operation is non-pure *) List.for_all no_side_effect xs + | Array_append (a,b) + | String_append (a,b) | Seq (a,b) -> no_side_effect a && no_side_effect b - | _ -> false + | Caml_block_length e + | Array_length e + | String_length e + | Bytes_length e + | Function_length e + | Char_of_int e + | Char_to_int e + | Caml_block_tag e + | Typeof e + -> no_side_effect e + | Bin (op, a, b) -> + op != Eq && no_side_effect a && no_side_effect b + | Math _ + | Array_of_size _ + | Array_copy _ + (* | Tag_ml_obj _ *) + | Int_of_boolean _ + + | Not _ + | String_of_small_int_array _ + | Json_stringify _ + | Anything_to_string _ + | Dump _ + | Cond _ + + | FlatCall _ + | Call _ + | Dot _ + | New _ + | Caml_uninitialized_obj _ + | String_access _ + | Object _ + | Caml_block_set_tag _ + | Caml_block_set_length _ (* actually true? *) + -> false let no_side_effect_expression (x : J.expression) = no_side_effect x @@ -181,3 +218,13 @@ let rev_toplevel_flatten block = | x :: xs -> aux (x :: acc) xs in aux [] block + +let rec is_constant (x : J.expression) = + match x.expression_desc with + | Access (a,b) -> is_constant a && is_constant b + | Str (b,_) -> b + | Number _ -> true (* Can be refined later *) + | Array (xs,_mutable_flag) -> List.for_all is_constant xs + | Caml_block(xs, Immutable, tag, _) + -> List.for_all is_constant xs && is_constant tag + | _ -> false diff --git a/jscomp/js_analyzer.mli b/jscomp/js_analyzer.mli index f6742eeacf..44549e9075 100644 --- a/jscomp/js_analyzer.mli +++ b/jscomp/js_analyzer.mli @@ -60,3 +60,5 @@ val rev_flatten_seq : J.expression -> J.block val rev_toplevel_flatten : J.block -> J.block (** return the block in reverse order *) + +val is_constant : J.expression -> bool diff --git a/jscomp/js_config.ml b/jscomp/js_config.ml index 8ba1987a45..eae9302e97 100644 --- a/jscomp/js_config.ml +++ b/jscomp/js_config.ml @@ -85,7 +85,7 @@ let stdlib_set = String_set.of_list [ let runtime_set = String_set.of_list [ "caml_array.js"; "caml_float.js"; - "caml_obj_runtime.js"; + "caml_obj.js"; "caml_bigarray.js"; "caml_format.js"; "caml_oo.js"; @@ -98,6 +98,7 @@ let runtime_set = String_set.of_list [ "caml_curry.js"; "caml_file.js"; "caml_lexer.js"; + "caml_parser.js"; "caml_string.js" (* "caml_sys.js"; *) (* "caml_unix.js"; *) @@ -114,9 +115,9 @@ let io = "Caml_io" let sys = "Caml_sys" -let lex_parse = "Caml_lexer" - -let obj_runtime = "Caml_obj_runtime" +let lexer = "Caml_lexer" +let parser = "Caml_parser" +let obj_runtime = "Caml_obj" let array = "Caml_array" @@ -128,3 +129,4 @@ let float = "Caml_float" let oo = "Caml_oo" let curry = "Caml_curry" +let internalMod = "Caml_internalMod" diff --git a/jscomp/js_config.mli b/jscomp/js_config.mli index 2ffc79dbce..6399f91d28 100644 --- a/jscomp/js_config.mli +++ b/jscomp/js_config.mli @@ -40,8 +40,8 @@ val oo : string val sys : string -val lex_parse : string - +val lexer : string +val parser : string val obj_runtime : string val array : string @@ -54,5 +54,5 @@ val float : string val curry : string - +val internalMod : string diff --git a/jscomp/js_dump.ml b/jscomp/js_dump.ml index 610ec2b6d2..7904a90dba 100644 --- a/jscomp/js_dump.ml +++ b/jscomp/js_dump.ml @@ -89,6 +89,7 @@ module L = struct let strict_directive = "'use strict';" let curry = "curry" (* curry arbitrary args *) + let tag = "tag" end let return_indent = (String.length L.return / Ext_pp.indent_length) @@ -420,17 +421,17 @@ and if l > 15 then P.paren_group f 1 action else action () - | Tag_ml_obj e -> - P.group f 1 (fun _ -> - P.string f "Object.defineProperty"; - P.paren_group f 1 (fun _ -> - let cxt = expression 1 cxt f e in - P.string f L.comma; - P.space f ; - P.string f {|"##ml"|}; - P.string f L.comma; - P.string f {|{"value" : true, "writable" : false}|} ; - cxt )) + (* | Tag_ml_obj e -> *) + (* P.group f 1 (fun _ -> *) + (* P.string f "Object.defineProperty"; *) + (* P.paren_group f 1 (fun _ -> *) + (* let cxt = expression 1 cxt f e in *) + (* P.string f L.comma; *) + (* P.space f ; *) + (* P.string f {|"##ml"|}; *) + (* P.string f L.comma; *) + (* P.string f {|{"value" : true, "writable" : false}|} ; *) + (* cxt )) *) | FlatCall(e,el) -> P.group f 1 (fun _ -> @@ -580,6 +581,18 @@ and P.string f "typeof"; P.space f; expression 13 cxt f e + | Caml_block_set_tag(a,b) -> + expression_desc cxt l f + (Bin(Eq, + {expression_desc = Caml_block_tag a; comment = None}, + b + )) + | Caml_block_set_length(a,b) -> + expression_desc cxt l f + (Bin(Eq, + {expression_desc = Caml_block_length a; comment = None}, + b + )) | Bin (Eq, {expression_desc = Var i }, {expression_desc = ( @@ -744,7 +757,45 @@ and | []| [ _ ] -> P.bracket_group f 1 @@ fun _ -> array_element_list cxt f el | _ -> P.bracket_vgroup f 1 @@ fun _ -> array_element_list cxt f el end + | Caml_uninitialized_obj (tag, size) + -> + expression_desc cxt l f (Object [Length, size ; Tag, tag]) + | Caml_block( el, mutable_flag, tag, tag_info) + -> + (* Note that, if we ignore more than tag [0] we loose some information + with regard tag *) + begin match tag.expression_desc, tag_info with + + | Number (Int { i = 0 ; _}) , + (Tuple | Array | Variant _ | Record | NA + | Constructor ("Some" | "::")) + (* Hack to optimize option which is really pervasive in ocaml, + we need concrete benchmark to support this + *) + -> expression_desc cxt l f (Array (el, mutable_flag)) + (* TODO: for numbers like 248, 255 we can reverse engineer to make it + [Obj.xx_flag], but we can not do this in runtime libraries + *) + | _, _ + -> + expression_desc cxt l f + (J.Object ( + let length, rev_list = + List.fold_left (fun (i,acc) v -> + (i+1, (Js_op.Int_key i, v) :: acc) + ) (0, []) el in + List.rev_append rev_list + [(Js_op.Length, E.int length) ; (Js_op.Tag, tag)] + ) + ) + end + | Caml_block_tag e -> + P.group f 1 (fun _ -> + let cxt = expression 15 cxt f e in + P.string f L.dot ; + P.string f L.tag ; + cxt) | Access (e, e') | String_access (e,e') @@ -757,7 +808,8 @@ and in if l > 15 then P.paren_group f 1 action else action () - | Array_length e | String_length e | Bytes_length e | Function_length e -> + | Array_length e | String_length e | Bytes_length e + | Function_length e | Caml_block_length e -> let action () = (** Todo: check parens *) let cxt = expression 15 cxt f e in P.string f L.dot; @@ -840,24 +892,27 @@ and P.brace_vgroup f 1 @@ fun _ -> property_name_and_value_list cxt f lst -and property_name cxt f (s : J.property_name) : Ext_pp_scope.t = - pp_string f ~utf:true ~quote:(best_string_quote s) s; cxt +and property_name cxt f (s : J.property_name) : unit = + match s with + | Tag -> P.string f L.tag + | Length -> P.string f L.length + | Key s -> + pp_string f ~utf:true ~quote:(best_string_quote s) s + | Int_key i -> P.string f (string_of_int i) and property_name_and_value_list cxt f l : Ext_pp_scope.t = match l with | [] -> cxt | [(pn, e)] -> - P.group f 0 @@ fun _ -> - let cxt = property_name cxt f pn in - P.string f L.colon; - P.space f; - expression 1 cxt f e + property_name cxt f pn ; + P.string f L.colon; + P.space f; + expression 1 cxt f e | (pn, e) :: r -> - let cxt = P.group f 0 @@ fun _ -> - let cxt = property_name cxt f pn in - P.string f L.colon; - P.space f; - expression 1 cxt f e in + property_name cxt f pn ; + P.string f L.colon; + P.space f; + let cxt = expression 1 cxt f e in P.string f L.comma; P.newline f; property_name_and_value_list cxt f r @@ -973,14 +1028,18 @@ and statement_desc top cxt f (s : J.statement_desc) : Ext_pp_scope.t = let rec need_paren (e : J.expression) = match e.expression_desc with | Call ({expression_desc = Fun _; },_,_) -> true - + | Caml_uninitialized_obj _ | Fun _ | Object _ -> true + | Caml_block_set_tag _ + | Caml_block_length _ + | Caml_block_set_length _ | Anything_to_string _ | String_of_small_int_array _ | Call _ | Array_append _ | Array_copy _ - | Tag_ml_obj _ + (* | Tag_ml_obj _ *) + | Caml_block_tag _ | Seq _ | Dot _ | Cond _ @@ -1000,6 +1059,7 @@ and statement_desc top cxt f (s : J.statement_desc) : Ext_pp_scope.t = | Var _ | Str _ | Array _ + | Caml_block _ | FlatCall _ | Typeof _ | Function_length _ diff --git a/jscomp/js_fold.ml b/jscomp/js_fold.ml index 2d96f9e7e7..06b6d34ee4 100644 --- a/jscomp/js_fold.ml +++ b/jscomp/js_fold.ml @@ -46,6 +46,7 @@ class virtual fold = let o = o#ident _x in let o = o#option (fun o -> o#expression) _x_i1 in let o = o#property _x_i2 in let o = o#ident_info _x_i3 in o + method tag_info : tag_info -> 'self_type = o#unknown method statement_desc : statement_desc -> 'self_type = function | Block _x -> let o = o#block _x in o @@ -124,6 +125,7 @@ class virtual fold = *) (* shallow copy, like [x.slice] *) (* For [caml_array_append]*) + (* | Tag_ml_obj of expression *) (* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence [typeof] is an operator *) @@ -201,6 +203,20 @@ class virtual fold = examples like "use asm;" and our compiler may generate "error;..." which is better to leave it alone *) + (* [tag] and [size] tailed for [Obj.new_block] *) + (* For setter, it still return the value of expression, + we can not use + {[ + type 'a access = Get | Set of 'a + ]} + in another module, since it will break our code generator + [Caml_block_tag] can return [undefined], + you have to use [E.tag] in a safe way + *) + (* It will just fetch tag, to make it safe, when creating it, + we need apply "|0", we don't do it in the + last step since "|0" can potentially be optimized + *) (* pure*) (* pure *) (* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block block can be nested, specified in ES3 @@ -294,7 +310,7 @@ class virtual fold = method return_expression : return_expression -> 'self_type = fun { return_value = _x } -> let o = o#expression _x in o method required_modules : required_modules -> 'self_type = o#unknown - method property_name : property_name -> 'self_type = o#string + method property_name : property_name -> 'self_type = o#unknown method property_map : property_map -> 'self_type = o#list (fun o (_x, _x_i1) -> @@ -334,7 +350,6 @@ class virtual fold = | Array_copy _x -> let o = o#expression _x in o | Array_append (_x, _x_i1) -> let o = o#expression _x in let o = o#expression _x_i1 in o - | Tag_ml_obj _x -> let o = o#expression _x in o | String_append (_x, _x_i1) -> let o = o#expression _x in let o = o#expression _x_i1 in o | Int_of_boolean _x -> let o = o#expression _x in o @@ -379,6 +394,18 @@ class virtual fold = | Array (_x, _x_i1) -> let o = o#list (fun o -> o#expression) _x in let o = o#mutable_flag _x_i1 in o + | Caml_block (_x, _x_i1, _x_i2, _x_i3) -> + let o = o#list (fun o -> o#expression) _x in + let o = o#mutable_flag _x_i1 in + let o = o#expression _x_i2 in let o = o#tag_info _x_i3 in o + | Caml_uninitialized_obj (_x, _x_i1) -> + let o = o#expression _x in let o = o#expression _x_i1 in o + | Caml_block_tag _x -> let o = o#expression _x in o + | Caml_block_set_tag (_x, _x_i1) -> + let o = o#expression _x in let o = o#expression _x_i1 in o + | Caml_block_length _x -> let o = o#expression _x in o + | Caml_block_set_length (_x, _x_i1) -> + let o = o#expression _x in let o = o#expression _x_i1 in o | Number _x -> let o = o#number _x in o | Object _x -> let o = o#property_map _x in o method expression : expression -> 'self_type = diff --git a/jscomp/js_helper.ml b/jscomp/js_helper.ml index a66d328ded..9862a32c74 100644 --- a/jscomp/js_helper.ml +++ b/jscomp/js_helper.ml @@ -82,13 +82,6 @@ let rec extract_non_pure (x : J.expression) = (* match aux x with *) (* | `Empty -> Js_output.dummy *) -let rec is_constant (x : J.expression) = - match x.expression_desc with - | Access (a,b) -> is_constant a && is_constant b - | Str (b,_) -> b - | Number _ -> true (* Can be refined later *) - | Array (xs,_mutable_flag) -> List.for_all is_constant xs - | _ -> false module Exp = struct (* type nonrec t = t a [bug in pretty printer] *) @@ -145,6 +138,12 @@ module Exp = struct comment } + let dummy_obj ?comment () : t = + {comment ; expression_desc = Object []} + + let is_instance_array ?comment e : t = + {comment; expression_desc = Bin(InstanceOf, e , str "Array") } + (* TODO: complete pure ... *) @@ -312,8 +311,9 @@ module Exp = struct let obj ?comment properties : t = {expression_desc = Object properties; comment } - let tag_ml_obj ?comment e : t = - {comment; expression_desc = Tag_ml_obj e } + let tag_ml_obj ?comment e : t = + e (* tag is enough *) + (* {comment; expression_desc = Tag_ml_obj e } *) (* currently only in method call, no dependency introduced *) @@ -445,11 +445,13 @@ module Exp = struct let rec econd ?comment (b : t) (t : t) (f : t) : t = match b.expression_desc , t.expression_desc, f.expression_desc with + | Number ((Int { i = 0; _}) ), _, _ -> f (* TODO: constant folding: could be refined *) | (Number _ | Array _), _, _ -> t (* a block can not be false in OCAML, CF - relies on flow inference*) - + | (Bin (Bor, v , {expression_desc = Number (Int {i = 0 ; _})})), _, _ + -> econd v t f | ((Bin ((EqEqEq, {expression_desc = Number (Int { i = 0; _}); _},x)) | Bin (EqEqEq, x,{expression_desc = Number (Int { i = 0; _});_}))), _, _ -> @@ -523,10 +525,48 @@ module Exp = struct match e0.expression_desc, e1.expression_desc with | Number (Int {i = i0 ; _}), Number (Int {i = i1; }) -> bool (i0 = i1) + | (Bin(Bor, + {expression_desc = Number(Int {i = 0; _})}, + ({expression_desc = Caml_block_tag _; _} as a )) + | + Bin(Bor, + ({expression_desc = Caml_block_tag _; _} as a), + {expression_desc = Number (Int {i = 0; _})})), + Number (Int {i = 0; _}) + -> (** (x.tag | 0) === 0 *) + not a + | (Bin(Bor, + {expression_desc = Number(Int {i = 0; _})}, + ({expression_desc = Caml_block_tag _; _} as a )) + | + Bin(Bor, + ({expression_desc = Caml_block_tag _; _} as a), + {expression_desc = Number (Int {i = 0; _})})) + , Number _ -> (* for sure [i != 0 ]*) + (* since a is integer, if we guarantee there is no overflow + of a + then [a | 0] is a nop unless a is undefined + (which is applicable when applied to tag), + obviously tag can not be overflowed. + if a is undefined, then [ a|0===0 ] is true + while [a === 0 ] is not true + [a|0 === non_zero] is false and [a===non_zero] is false + so we can not eliminate when the tag is zero + *) + float_equal ?comment a e1 | Number (Float {f = f0; _}), Number (Float {f = f1 ; }) when f0 = f1 -> true_ - | _ -> - to_ocaml_boolean {expression_desc = Bin(EqEqEq, e0,e1); comment} + + | Char_to_int a , Char_to_int b -> + float_equal ?comment a b + | Char_to_int a , Number (Int {i; c = Some v}) + | Number (Int {i; c = Some v}), Char_to_int a -> + float_equal ?comment a (str (String.make 1 v)) + | Char_of_int a , Char_of_int b -> + float_equal ?comment a b + + | _ -> + to_ocaml_boolean {expression_desc = Bin(EqEqEq, e0,e1); comment} let int_equal = float_equal let rec string_equal ?comment (e0 : t) (e1 : t) : t = match e0.expression_desc, e1.expression_desc with @@ -539,6 +579,16 @@ module Exp = struct let arr ?comment mt es : t = {expression_desc = Array (es,mt) ; comment} + let make_block ?comment tag tag_info es mutable_flag : t = + { + expression_desc = Caml_block( es, mutable_flag, tag,tag_info) ; + comment = (match comment with + | None -> Lam_compile_util.comment_of_tag_info tag_info + | _ -> comment) + } + + let uninitialized_object ?comment tag size : t = + { expression_desc = Caml_uninitialized_obj(tag,size); comment } let uninitialized_array ?comment (e : t) : t = match e.expression_desc with @@ -613,8 +663,17 @@ module Exp = struct let null ?comment () = js_global ?comment "null" - let tag ?comment e = index ?comment e 0 - + let tag ?comment e : t = + {expression_desc = + Bin (Bor, {expression_desc = Caml_block_tag e; comment }, int 0 ); + comment = None } + let set_tag ?comment e tag : t = + seq {expression_desc = Caml_block_set_tag (e,tag); comment } (unit ()) + + let set_length ?comment e tag : t = + seq {expression_desc = Caml_block_set_length (e,tag); comment } (unit ()) + let obj_length ?comment e : t = + {expression_desc = Caml_block_length e; comment } (* Arithmatic operations TODO: distinguish between int and float TODO: Note that we have to use Int64 to avoid integer overflow, this is fine @@ -661,6 +720,7 @@ module Exp = struct [l;r], _), Number (Int {i = 0}) -> int_comp cmp l r (* = 0 > 0 < 0 *) + | Ceq, _, _ -> int_equal e0 e1 | _ -> to_ocaml_boolean @@ bin ?comment (Lam_compile_util.jsop_of_comp cmp) e0 e1 @@ -1068,25 +1128,29 @@ module Stmt = struct turn [Le] -> into [Ge] *) -> block then_ :: acc - - | ( - (Bin ((EqEqEq, {expression_desc = Number (Int {i = 0; _}); _},e)) | - Bin (EqEqEq, e,{expression_desc = Number (Int {i = 0; _});_})) - ), _, else_ - (* TODO: optimize in general of preciate information based on type system - like: [if_], [econd] - *) - -> + | Bin (Bor , a, {expression_desc = Number (Int { i = 0 ; _})}), _, _ + | Bin (Bor , {expression_desc = Number (Int { i = 0 ; _})}, a), _, _ + -> + aux ?comment a then_ else_ acc + + | ( + (Bin (((EqEqEq ), {expression_desc = Number (Int {i = 0; _}); _},e)) | + Bin ((EqEqEq ), e,{expression_desc = Number (Int {i = 0; _});_})) + ), _, else_ + (* TODO: optimize in general of preciate information based on type system + like: [if_], [econd] + *) + -> aux ?comment e else_ then_ acc - | ((Bin (Gt, - ({expression_desc = - (String_length _ - | Array_length _ | Bytes_length _ | Function_length _ ); - _} as e ), {expression_desc = Number (Int { i = 0; _})})) + | ((Bin (Gt, + ({expression_desc = + (String_length _ + | Array_length _ | Bytes_length _ | Function_length _ ); + _} as e ), {expression_desc = Number (Int { i = 0; _})})) - | Int_of_boolean e), _ , _ - -> + | Int_of_boolean e), _ , _ + -> (** Add comment when simplified *) aux ?comment e then_ else_ acc diff --git a/jscomp/js_helper.mli b/jscomp/js_helper.mli index fc9349bda5..ccb43b5f58 100644 --- a/jscomp/js_helper.mli +++ b/jscomp/js_helper.mli @@ -26,7 +26,7 @@ val no_side_effect : J.expression -> bool -val is_constant : J.expression -> bool + (** check if a javascript ast is constant The better signature might be @@ -177,6 +177,13 @@ module Exp : sig val arr : ?comment:string -> J.mutable_flag -> J.expression list -> t + val make_block : + ?comment:string -> + J.expression -> J.tag_info -> J.expression list -> J.mutable_flag -> t + + val uninitialized_object : + ?comment:string -> J.expression -> J.expression -> t + val uninitialized_array : unary_op val seq : binary_op @@ -214,12 +221,24 @@ module Exp : sig val null : ?comment:string -> unit -> t val tag : ?comment:string -> J.expression -> t - + val set_tag : ?comment:string -> J.expression -> J.expression -> t + + (** Note that this is coupled with how we encode block, if we use the + `Object.defineProperty(..)` since the array already hold the length, + this should be a nop + *) + + val set_length : ?comment:string -> J.expression -> J.expression -> t + val obj_length : ?comment:string -> J.expression -> t val to_ocaml_boolean : unary_op val and_ : binary_op - val or_ : binary_op + + (** we don't expose a general interface, since a general interface is generally not safe *) + val is_instance_array : unary_op + (** used combined with [caml_update_dummy]*) + val dummy_obj : ?comment:string -> unit -> t (** convert a block to expresion by using IIFE *) val of_block : ?comment:string -> J.statement list -> J.expression -> t diff --git a/jscomp/js_map.ml b/jscomp/js_map.ml index 7d47df2d95..dc7010848b 100644 --- a/jscomp/js_map.ml +++ b/jscomp/js_map.ml @@ -55,6 +55,7 @@ class virtual map = in { ident = _x; value = _x_i1; property = _x_i2; ident_info = _x_i3; } + method tag_info : tag_info -> tag_info = o#unknown method statement_desc : statement_desc -> statement_desc = function | Block _x -> let _x = o#block _x in Block _x @@ -137,6 +138,7 @@ class virtual map = *) (* shallow copy, like [x.slice] *) (* For [caml_array_append]*) + (* | Tag_ml_obj of expression *) (* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence [typeof] is an operator *) @@ -214,6 +216,20 @@ class virtual map = examples like "use asm;" and our compiler may generate "error;..." which is better to leave it alone *) + (* [tag] and [size] tailed for [Obj.new_block] *) + (* For setter, it still return the value of expression, + we can not use + {[ + type 'a access = Get | Set of 'a + ]} + in another module, since it will break our code generator + [Caml_block_tag] can return [undefined], + you have to use [E.tag] in a safe way + *) + (* It will just fetch tag, to make it safe, when creating it, + we need apply "|0", we don't do it in the + last step since "|0" can potentially be optimized + *) (* pure*) (* pure *) (* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block block can be nested, specified in ES3 @@ -314,7 +330,7 @@ class virtual map = let _x = o#expression _x in { return_value = _x; } method required_modules : required_modules -> required_modules = o#unknown - method property_name : property_name -> property_name = o#string + method property_name : property_name -> property_name = o#unknown method property_map : property_map -> property_map = o#list (fun o (_x, _x_i1) -> @@ -359,7 +375,6 @@ class virtual map = | Array_append (_x, _x_i1) -> let _x = o#expression _x in let _x_i1 = o#expression _x_i1 in Array_append (_x, _x_i1) - | Tag_ml_obj _x -> let _x = o#expression _x in Tag_ml_obj _x | String_append (_x, _x_i1) -> let _x = o#expression _x in let _x_i1 = o#expression _x_i1 in String_append (_x, _x_i1) @@ -418,6 +433,25 @@ class virtual map = | Array (_x, _x_i1) -> let _x = o#list (fun o -> o#expression) _x in let _x_i1 = o#mutable_flag _x_i1 in Array (_x, _x_i1) + | Caml_block (_x, _x_i1, _x_i2, _x_i3) -> + let _x = o#list (fun o -> o#expression) _x in + let _x_i1 = o#mutable_flag _x_i1 in + let _x_i2 = o#expression _x_i2 in + let _x_i3 = o#tag_info _x_i3 + in Caml_block (_x, _x_i1, _x_i2, _x_i3) + | Caml_uninitialized_obj (_x, _x_i1) -> + let _x = o#expression _x in + let _x_i1 = o#expression _x_i1 + in Caml_uninitialized_obj (_x, _x_i1) + | Caml_block_tag _x -> let _x = o#expression _x in Caml_block_tag _x + | Caml_block_set_tag (_x, _x_i1) -> + let _x = o#expression _x in + let _x_i1 = o#expression _x_i1 in Caml_block_set_tag (_x, _x_i1) + | Caml_block_length _x -> + let _x = o#expression _x in Caml_block_length _x + | Caml_block_set_length (_x, _x_i1) -> + let _x = o#expression _x in + let _x_i1 = o#expression _x_i1 in Caml_block_set_length (_x, _x_i1) | Number _x -> let _x = o#number _x in Number _x | Object _x -> let _x = o#property_map _x in Object _x method expression : expression -> expression = diff --git a/jscomp/js_of_lam_array.ml b/jscomp/js_of_lam_array.ml index 754e01791b..f6032ca99a 100644 --- a/jscomp/js_of_lam_array.ml +++ b/jscomp/js_of_lam_array.ml @@ -47,9 +47,10 @@ module E = Js_helper.Exp let make_array mt (kind : Lambda.array_kind) args = match kind with | Pgenarray - | Paddrarray - | Pintarray (* -> E.arr (E.int ~comment:"array" 0 :: args) (\* Parrayref(u|s) *\) *) - | Pfloatarray -> E.arr ~comment:"array" mt args + | Paddrarray -> E.arr ~comment:"array" mt args + | Pintarray -> E.arr ~comment:"int array" mt args + (* -> E.arr (E.int ~comment:"array" 0 :: args) (\* Parrayref(u|s) *\) *) + | Pfloatarray -> E.arr ~comment:"float array" mt args let set_array e e0 e1 = E.assign (E.access e e0) e1 diff --git a/jscomp/js_of_lam_block.ml b/jscomp/js_of_lam_block.ml index ae05b28bd1..d6b5e98ec9 100644 --- a/jscomp/js_of_lam_block.ml +++ b/jscomp/js_of_lam_block.ml @@ -26,20 +26,22 @@ module E = Js_helper.Exp about immutablility *) let make_block mutable_flag (tag_info : Lambda.tag_info) tag args = - match mutable_flag, tag_info with - | _, Array -> Js_of_lam_array.make_array mutable_flag Pgenarray args - | _, ( Tuple | Variant _ ) -> (** TODO: check with inline record *) - E.arr Immutable - (E.int ?comment:(Lam_compile_util.comment_of_tag_info tag_info) tag - :: args) - | _, _ -> - E.arr mutable_flag - (E.int ?comment:(Lam_compile_util.comment_of_tag_info tag_info) tag - :: args) - -let field e i = E.index e (i + 1) - -let set_field e i e0 = (E.assign (E.index e (i+1)) e0) + + match mutable_flag, tag_info with + | _, Array -> Js_of_lam_array.make_array mutable_flag Pgenarray args + | _ , _ -> E.make_block tag tag_info args mutable_flag + (* | _, ( Tuple | Variant _ ) -> (\** TODO: check with inline record *\) *) + (* E.arr Immutable *) + (* (E.int ?comment:(Lam_compile_util.comment_of_tag_info tag_info) tag *) + (* :: args) *) + (* | _, _ -> *) + (* E.arr mutable_flag *) + (* (E.int ?comment:(Lam_compile_util.comment_of_tag_info tag_info) tag *) + (* :: args) *) + +let field e i = E.index e i + +let set_field e i e0 = (E.assign (E.index e i) e0) diff --git a/jscomp/js_of_lam_block.mli b/jscomp/js_of_lam_block.mli index a6081bedee..2c5d442658 100644 --- a/jscomp/js_of_lam_block.mli +++ b/jscomp/js_of_lam_block.mli @@ -22,7 +22,9 @@ (** Utilities for creating block of lambda expression in JS IR *) -val make_block : Js_op.mutable_flag -> Lambda.tag_info -> int -> J.expression list -> J.expression +val make_block : + Js_op.mutable_flag -> Lambda.tag_info -> + J.expression -> J.expression list -> J.expression val field : J.expression -> int -> J.expression diff --git a/jscomp/js_of_lam_exception.ml b/jscomp/js_of_lam_exception.ml new file mode 100644 index 0000000000..0db84e4ee0 --- /dev/null +++ b/jscomp/js_of_lam_exception.ml @@ -0,0 +1,54 @@ +(* OCamlScript compiler + * Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +(* Author: Hongbo Zhang *) + +(** An pattern match on {!caml_set_oo_id args} + Note that in the trunk, it is immutable by default now + *) +module E = Js_helper.Exp + +let match_exception_def (args : J.expression list) = + match args with + | [{ expression_desc = + Caml_block ( + [ exception_str; + {expression_desc = J.Number (Int { i = 0; _}); _} + ], + mutable_flag, + {expression_desc = J.Number (Int {i = object_tag; _}); _}, _ ); + _} ] -> + if object_tag = Obj.object_tag then + Some ( exception_str, mutable_flag) + else + None + | _ -> None + +(* Sync up with [caml_set_oo_id] *) +let make_exception id exception_str mutable_flag : J.expression = + { expression_desc = + Caml_block ( + [exception_str ; + id], + mutable_flag, + (* TODO: combined with `_001` optimization *) + E.int (Obj.object_tag), + NA + ); + comment = None + } diff --git a/jscomp/js_of_lam_exception.mli b/jscomp/js_of_lam_exception.mli new file mode 100644 index 0000000000..2e54371eea --- /dev/null +++ b/jscomp/js_of_lam_exception.mli @@ -0,0 +1,29 @@ +(* OCamlScript compiler + * Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +(* Author: Hongbo Zhang *) + +val match_exception_def : J.expression list -> + (J.expression * J.mutable_flag) option + + + +val make_exception : + J.expression -> J.expression -> J.mutable_flag -> J.expression + + diff --git a/jscomp/js_of_lam_module.ml b/jscomp/js_of_lam_module.ml new file mode 100644 index 0000000000..096c68f9ca --- /dev/null +++ b/jscomp/js_of_lam_module.ml @@ -0,0 +1,36 @@ +(* OCamlScript compiler + * Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +(* Author: Hongbo Zhang *) + +module E = Js_helper.Exp + +let make ?comment (args : J.expression list) = + E.make_block + ?comment (E.int 0) + NA (* TODO: it should be Module*) args Immutable + +let is_empty_shape (shape : J.expression) = + match shape with + | {expression_desc = + Caml_block([ + {expression_desc = + Caml_block ([],_,_,_) ; _ } + ],_,_,_) ; _} + -> true + | _ -> false diff --git a/jscomp/js_of_lam_module.mli b/jscomp/js_of_lam_module.mli new file mode 100644 index 0000000000..ce98cba3a5 --- /dev/null +++ b/jscomp/js_of_lam_module.mli @@ -0,0 +1,24 @@ +(* OCamlScript compiler + * Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +(* Author: Hongbo Zhang *) + +val make : ?comment:string -> J.expression list -> J.expression + +val is_empty_shape : + J.expression -> bool diff --git a/jscomp/js_of_lam_record.ml b/jscomp/js_of_lam_record.ml index 8f77683710..408dd5df9e 100644 --- a/jscomp/js_of_lam_record.ml +++ b/jscomp/js_of_lam_record.ml @@ -24,4 +24,10 @@ module E = Js_helper.Exp (* TODO: add label to the comment *) let make mutable_flag (args : (string * J.expression) list) = - E.arr mutable_flag (E.int 0 :: List.map snd args) + E.make_block ~comment:"record" + (E.int 0) Record (List.map snd args) mutable_flag + (* E.arr mutable_flag (E.int 0 :: List.map snd args) *) + +let field e i = E.index e i + + diff --git a/jscomp/js_of_lam_record.mli b/jscomp/js_of_lam_record.mli index e49e107676..96eaa4a37b 100644 --- a/jscomp/js_of_lam_record.mli +++ b/jscomp/js_of_lam_record.mli @@ -21,3 +21,5 @@ (** Utilities for compiling lambda record into JS IR *) val make : J.mutable_flag -> (string * J.expression) list -> J.expression + +val field : J.expression -> int ->J.expression diff --git a/jscomp/js_of_lam_tuple.ml b/jscomp/js_of_lam_tuple.ml index 100df83bca..335e35dd33 100644 --- a/jscomp/js_of_lam_tuple.ml +++ b/jscomp/js_of_lam_tuple.ml @@ -23,4 +23,5 @@ module E = Js_helper.Exp let make (args : J.expression list) = - E.arr Immutable (E.int 0 :: args) + E.make_block ~comment:"tuple" (E.int 0) Tuple args Immutable + (* E.arr Immutable (E.int 0 :: args) *) diff --git a/jscomp/js_op.ml b/jscomp/js_op.ml index 026a265f7d..b26c849c23 100644 --- a/jscomp/js_op.ml +++ b/jscomp/js_op.ml @@ -20,6 +20,8 @@ + + (** Define some basic types used in JS IR *) type binop = @@ -33,6 +35,7 @@ type binop = | And | EqEqEq | NotEqEq + | InstanceOf | Lt | Le @@ -133,6 +136,15 @@ type property = Lambda.let_kind = | StrictOpt | Variable +type property_name = + | Key of string + | Int_key of int + | Tag + | Length + +type 'a access = + | Getter + | Setter type int_or_char = { i : int; c : char option @@ -194,6 +206,15 @@ type ident_info = { type exports = Ident.t list type required_modules = (Ident.t * string) list + +type tag_info = Lambda.tag_info = + | Constructor of string + | Tuple + | Array + | Variant of string + | Record + | NA + (** TODO: define constant - for better constant folding *) (* type constant = *) (* | Const_int of int *) diff --git a/jscomp/js_op_util.ml b/jscomp/js_op_util.ml index 483002904b..eff863c38a 100644 --- a/jscomp/js_op_util.ml +++ b/jscomp/js_op_util.ml @@ -31,7 +31,7 @@ let op_prec (op : Js_op.binop ) = | Or -> 3, 3, 3 | And -> 4, 4, 4 | EqEqEq | NotEqEq -> 8, 8, 9 - | Gt | Ge | Lt | Le -> 9, 9, 10 + | Gt | Ge | Lt | Le | InstanceOf -> 9, 9, 10 | Bor -> 5, 5, 5 | Bxor -> 6, 6, 6 | Band -> 7, 7, 7 @@ -72,7 +72,7 @@ let op_str (op : Js_op.binop) = | Le -> "<=" | Gt -> ">" | Ge -> ">=" - + | InstanceOf -> "instanceof" let op_int_str (op : Js_op.int_op) = match op with @@ -131,3 +131,8 @@ let same_vident (x : J.vident) (y : J.vident) = Ident.same x0 y0 && same_kind k0 k1 && same_str_opt str_opt0 str_opt1 | Id _, Qualified _ | Qualified _, Id _ -> false + +let of_lam_mutable_flag (x : Asttypes.mutable_flag) : Js_op.mutable_flag = + match x with + | Immutable -> Immutable + | Mutable -> Mutable diff --git a/jscomp/js_op_util.mli b/jscomp/js_op_util.mli index 9ecaff31e9..26afe2ad3d 100644 --- a/jscomp/js_op_util.mli +++ b/jscomp/js_op_util.mli @@ -35,3 +35,5 @@ val str_of_used_stats : Js_op.used_stats -> string val update_used_stats : J.ident_info -> Js_op.used_stats -> unit val same_vident : J.vident -> J.vident -> bool + +val of_lam_mutable_flag : Asttypes.mutable_flag -> Js_op.mutable_flag diff --git a/jscomp/js_pass_flatten_and_mark_dead.ml b/jscomp/js_pass_flatten_and_mark_dead.ml index 1ba1f0f29d..02c84e6995 100644 --- a/jscomp/js_pass_flatten_and_mark_dead.ml +++ b/jscomp/js_pass_flatten_and_mark_dead.ml @@ -173,45 +173,55 @@ let subst_map name = object (self) | Variable ({ ident ; property = (Strict | StrictOpt | Alias); - value = Some ({expression_desc = (Array ( _:: _ :: _ as ls, Immutable))} as array) + value = Some ( + {expression_desc = (Caml_block ( _:: _ :: _ as ls, Immutable, tag, tag_info) + )} as block) } as variable) -> (** If we do this, we should prevent incorrect inlning to inline it into an array :) do it only when block size is larger than one *) - let bindings = ref [] in - let e = List.mapi (fun i (x : J.expression) -> - match x.expression_desc with - | J.Var _ | Number _ | Str _ -> x - | _ -> - (* tradeoff, - when the block is small, it does not make - sense too much -- - bottomline, when the block size is one, no need to do - this - *) - let v' = self#expression x in - let match_id = - Ext_ident.create - (Printf.sprintf "%s_%03d" - ident.name i) in - bindings := (match_id , v') :: !bindings; - E.var match_id - ) ls in - let e = {array with expression_desc = Array(e, Immutable)} in - let () = self#add_substitue ident e in - let bindings = !bindings in - let original_statement = {v with statement_desc = - Variable {variable with value = Some e } + + let (_, e, bindings) = + List.fold_left + (fun (i,e, acc) (x : J.expression) -> + match x.expression_desc with + | J.Var _ | Number _ | Str _ + -> + (i + 1, x :: e, acc) + | _ -> + (* tradeoff, + when the block is small, it does not make + sense too much -- + bottomline, when the block size is one, no need to do + this + *) + let v' = self#expression x in + let match_id = + Ext_ident.create + (Printf.sprintf "%s_%03d" + ident.name i) in + (i + 1, E.var match_id :: e, (match_id, v') :: acc) + ) (0, [], []) ls in + let e = + {block with + expression_desc = + Caml_block(List.rev e, Immutable, tag, tag_info) + } in + let () = self#add_substitue ident e in + (* let bindings = !bindings in *) + let original_statement = + { v with + statement_desc = Variable {variable with value = Some e } } in - begin match bindings with + begin match bindings with | [] -> - original_statement + original_statement | _ -> - self#add_substitue ident e ; - S.block @@ - (Ext_list.rev_map_acc [original_statement] (fun (id,v) -> - S.define ~kind:Strict id v) bindings ) - end + (* self#add_substitue ident e ; *) + S.block @@ + (Ext_list.rev_map_acc [original_statement] (fun (id,v) -> + S.define ~kind:Strict id v) bindings ) + end | _ -> super#statement v method! expression x = @@ -219,7 +229,7 @@ let subst_map name = object (self) | Access ({expression_desc = Var (Id (id))}, {expression_desc = Number (Int {i; _})}) -> begin match Hashtbl.find self#get_substitution id with - | {expression_desc = Array (ls, Immutable) } + | {expression_desc = Caml_block (ls, Immutable, _, _) } -> (* user program can be wrong, we should not turn a runtime crash into compile time crash : ) diff --git a/jscomp/lam_compile.ml b/jscomp/lam_compile.ml index d417c50059..c8151b8693 100644 --- a/jscomp/lam_compile.ml +++ b/jscomp/lam_compile.ml @@ -175,6 +175,25 @@ and get_exp_with_args (cxt : Lam_compile_defs.cxt) lam args_lambda E.seq (E.dump Log args) (E.unit ()) | {name = "Pervasives"; _}, "prerr_endline", ([ _ ] as args) -> E.seq (E.dump Error args) (E.unit ()) + | {name = "CamlinternalMod"; _}, "update_mod" , + [ shape ; + _module ; + _ ] when Js_of_lam_module.is_empty_shape shape + -> + E.unit () + | {name = "CamlinternalMod"; _}, "init_mod" , + [ + _ ; + shape ; + (* Module [] + TODO: add a function [empty_shape] + This pattern match is fragile, since it depends + on how we compile [Lconst] + *) + ] when Js_of_lam_module.is_empty_shape shape + -> + E.dummy_obj () (* purely type definition*) + | _ -> @@ -278,7 +297,7 @@ and compile_recursive_let (cxt : Lam_compile_defs.cxt) (id : Ident.t) (arg : Lam could be improved for simple cases *) Js_output.of_block ( - b @ [S.exp(E.runtime_call Js_config.prim "caml_update_dummy" [ E.var id; v])]), + b @ [S.exp(E.runtime_call Js_config.obj_runtime "caml_update_dummy" [ E.var id; v])]), [id] (* S.define ~kind:Variable id (E.arr Mutable []):: *) | _ -> assert false @@ -320,17 +339,20 @@ and compile_recursive_lets cxt id_args : Js_output.t = | [] -> output_code | _ -> (Js_output.of_block @@ - List.map (fun id -> S.define ~kind:Variable id (E.arr Mutable [])) ids ) + List.map (fun id -> S.define ~kind:Variable id (E.dummy_obj ())) ids ) ++ output_code and compile_general_cases : 'a . ('a -> J.expression) -> + (J.expression -> J.expression -> J.expression) -> Lam_compile_defs.cxt -> - (?default:J.block -> ?declaration:Lambda.let_kind * Ident.t -> _ -> 'a J.case_clause list -> J.statement) -> + (?default:J.block -> + ?declaration:Lambda.let_kind * Ident.t -> + _ -> 'a J.case_clause list -> J.statement) -> _ -> ('a * Lambda.lambda) list -> default_case -> J.block - = fun f cxt switch v table default -> + = fun f eq cxt switch v table default -> let wrap (cxt : Lam_compile_defs.cxt) k = let cxt, define = match cxt.st with @@ -356,7 +378,7 @@ and compile_general_cases : | [(id,lam)], NonComplete -> wrap cxt @@ fun cxt define -> - [S.if_ ?declaration:define (E.triple_equal v (f id) ) + [S.if_ ?declaration:define (eq v (f id) ) (Js_output.to_block @@ compile_lambda cxt lam )] | ([(id,lam)], Default x) | ([(id,lam); (_,x)], Complete) @@ -364,7 +386,7 @@ and compile_general_cases : wrap cxt @@ fun cxt define -> let else_block = Js_output.to_block (compile_lambda cxt x) in let then_block = Js_output.to_block (compile_lambda cxt lam) in - [ S.if_ ?declaration:define (E.triple_equal v (f id) ) + [ S.if_ ?declaration:define (eq v (f id) ) then_block ~else_:else_block ] @@ -402,10 +424,10 @@ and compile_general_cases : in [switch ?default ?declaration v body] -and compile_cases cxt = compile_general_cases E.int cxt +and compile_cases cxt = compile_general_cases E.int E.int_equal cxt (fun ?default ?declaration e clauses -> S.int_switch ?default ?declaration e clauses) -and compile_string_cases cxt = compile_general_cases E.str cxt +and compile_string_cases cxt = compile_general_cases E.str E.string_equal cxt (fun ?default ?declaration e clauses -> S.string_switch ?default ?declaration e clauses) (* TODO: optional arguments are not good for high order currying *) @@ -1284,7 +1306,7 @@ and st should_return lam (List.concat args_code) - (E.call (Js_of_lam_array.ref_array (E.index obj' 1) label ) + (E.call (Js_of_lam_array.ref_array (Js_of_lam_record.field obj' 0) label ) (obj' :: args)) (* [E.int 1] is because we use array, when we change the runtime represenation, it needs to be adapted diff --git a/jscomp/lam_compile_const.ml b/jscomp/lam_compile_const.ml index 4575499ad9..4989a2307f 100644 --- a/jscomp/lam_compile_const.ml +++ b/jscomp/lam_compile_const.ml @@ -57,7 +57,8 @@ let rec translate (x : Lambda.structured_constant ) : J.expression = E.int ?comment:(Lam_compile_util.comment_of_pointer_info pointer_info) c | Const_block(tag, tag_info, xs ) -> - Js_of_lam_block.make_block NA tag_info tag (List.map translate xs) + Js_of_lam_block.make_block NA tag_info + (E.int tag) (List.map translate xs) | Const_float_array ars -> (* according to the compiler @@ -71,8 +72,10 @@ let rec translate (x : Lambda.structured_constant ) : J.expression = we deoptimized this in js backend? so it is actually mutable *) (* TODO-- *) - E.arr Mutable ~comment:"float array" + Js_of_lam_array.make_array Mutable Pfloatarray (List.map (fun x -> E.float x ) ars) + (* E.arr Mutable ~comment:"float array" *) + (* (List.map (fun x -> E.float x ) ars) *) | Const_immstring s -> (*TODO *) E.str s (* TODO: check *) diff --git a/jscomp/lam_compile_external_call.ml b/jscomp/lam_compile_external_call.ml index d133c99079..b2df3b5d77 100644 --- a/jscomp/lam_compile_external_call.ml +++ b/jscomp/lam_compile_external_call.ml @@ -252,31 +252,31 @@ let translate match prim_ty with | Some ty -> let _return_type, arg_types = Type_util.list_of_arrow ty in - let kvs = + let kvs : J.property_map = Ext_list.filter_map2 (fun (label, (ty : Types.type_expr)) (arg : J.expression) -> match ty.desc, Type_util.label_name label with | Tconstr(p,_, _), _ when Path.same p Predef.path_unit -> None | Tconstr(p,_,_), `Label label when Path.same p Predef.path_bool -> begin match arg.expression_desc with - | Number ((* Float { f = "0."}| *) Int { i = 0;_}) -> Some (label ,E.false_) - | Number _ -> Some (label,E.true_) - | _ -> Some ( label, (E.econd arg E.true_ E.false_)) + | Number ((* Float { f = "0."}| *) Int { i = 0;_}) -> Some (Js_op.Key label ,E.false_) + | Number _ -> Some (Js_op.Key label,E.true_) + | _ -> Some (Js_op.Key label, (E.econd arg E.true_ E.false_)) end | _, `Label label -> - Some ( label, arg) + Some (Js_op.Key label, arg) | _, `Optional label -> begin match (arg.expression_desc) with | Array ([x;y], _mutable_flag) -> - Some ( label, y) (*Invrariant: optional encoding*) + Some (Js_op.Key label, y) (*Invrariant: optional encoding*) | Number _ -> (*Invariant: None encoding*) None | _ -> (* FIXME: avoid duplicate evlauation of [arg] when it is not a variable [Var ] can only bd detected at runtime thing *) - Some ( label, + Some ( Key label, E.econd arg (* (E.bin EqEqEq (E.typeof arg) *) (* (E.str "number")) *) diff --git a/jscomp/lam_compile_global.ml b/jscomp/lam_compile_global.ml index fa23f18444..e666a3ad94 100644 --- a/jscomp/lam_compile_global.ml +++ b/jscomp/lam_compile_global.ml @@ -59,83 +59,14 @@ let get_exp (key : Lam_compile_env.key) : J.expression = then (** TODO: add module into taginfo*) let len = List.length sigs in (** TODO: could be optimized *) - E.arr Immutable (E.int ~comment:id.name 0 :: - Ext_list.init len (fun i -> E.ml_var_dot id - (Type_util.get_name sigs i )) - ) + Js_of_lam_module.make ~comment:id.name + (Ext_list.init len (fun i -> + E.ml_var_dot id + (Type_util.get_name sigs i ))) + + else E.ml_var id) -(* TODO: how nested module call would behave, - In the future, we should keep in track of if - it is fully applied from [Lapply] - Seems that the module dependency is tricky.. - should we depend on [Pervasives] or not? - - we can not do this correctly for the return value, - however we can inline the definition in Pervasives - TODO: - [Pervasives.print_endline] - [Pervasives.prerr_endline] - *) - -let get_exp_with_args (id : Ident.t) (pos : int) env (args : J.expression list) : J.expression = - - Lam_compile_env.find_and_add_if_not_exist (id,pos) env ~not_found:(fun id -> - (** This can not happen since this id should be already consulted by type checker - Worst case - {[ - E.index m (pos + 1) - ]} - shift by one (due to module encoding) - *) - E.str ~pure:false (Printf.sprintf "Err %s %d %d" - id.name - id.flags - pos - )) - - ~found:(fun {id; name;arity; _} -> - match id, name, args with - | {name = "Pervasives"; _}, "^", [ e0 ; e1] -> - E.string_append e0 e1 - | {name = "Pervasives"; _}, "string_of_int", [e] - -> E.int_to_string e - | {name = "Pervasives"; _}, "print_endline", ([ _ ] as args) -> - E.seq (E.dump Log args) (E.unit ()) - | {name = "Pervasives"; _}, "prerr_endline", ([ _ ] as args) -> - E.seq (E.dump Error args) (E.unit ()) - | _ -> - - - let rec aux (acc : J.expression) - (arity : Lam_stats.function_arities) args (len : int) = - match arity, len with - | _, 0 -> - acc (** All arguments consumed so far *) - | Determin (a, (x,_) :: rest, b), len -> - let x = - if x = 0 - then 1 - else x in (* Relax when x = 0 *) - if len >= x - then - let first_part, continue = (Ext_list.take x args) in - aux - (E.call ~info:{arity=Full} acc first_part) - (Determin (a, rest, b)) - continue (len - x) - else acc - (* alpha conversion now? -- - Since we did an alpha conversion before so it is not here - *) - | Determin (a, [], b ), _ -> - (* can not happen, unless it's an exception ? *) - E.call acc args - | NA, _ -> - E.call acc args - in - aux (E.ml_var_dot id name) arity args (List.length args ) - ) diff --git a/jscomp/lam_compile_group.ml b/jscomp/lam_compile_group.ml index 0da2c3175d..791f2daca2 100644 --- a/jscomp/lam_compile_group.ml +++ b/jscomp/lam_compile_group.ml @@ -379,7 +379,7 @@ let lambda_as_module (lam : Lambda.lambda) = begin Lam_current_unit.set_file filename ; - Lam_current_unit.iset_debug_file "caml_string.ml"; + Lam_current_unit.iset_debug_file "rec_module_test.ml"; Ext_pervasives.with_file_as_chan (Ext_filename.chop_extension ~loc:__LOC__ filename ^ ".js") (fun chan -> Js_dump.dump_deps_program (compile ~filename false env sigs lam) chan) diff --git a/jscomp/lam_compile_primitive.ml b/jscomp/lam_compile_primitive.ml index d9202818a8..991cdd6769 100644 --- a/jscomp/lam_compile_primitive.ml +++ b/jscomp/lam_compile_primitive.ml @@ -38,10 +38,9 @@ let translate (args : J.expression list) : J.expression = match prim with | Pmakeblock(tag, tag_info, mutable_flag ) -> (* RUNTIME *) - begin match mutable_flag with - | Immutable -> Js_of_lam_block.make_block Immutable tag_info tag args - | Mutable -> Js_of_lam_block.make_block Mutable tag_info tag args - end + Js_of_lam_block.make_block + (Js_op_util.of_lam_mutable_flag mutable_flag) + tag_info (E.int tag) args | Pfield i -> begin match args with | [ e ] -> Js_of_lam_block.field e i (* Invariant depends on runtime *) diff --git a/jscomp/lam_dispatch_primitive.ml b/jscomp/lam_dispatch_primitive.ml index 3b2578e425..64d935a458 100644 --- a/jscomp/lam_dispatch_primitive.ml +++ b/jscomp/lam_dispatch_primitive.ml @@ -395,14 +395,16 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_gc_get" -> (* unit -> Gc.control*) - E.arr NA [E.int 0; - E.int ~comment:"minor_heap_size" 0 ; - E.int ~comment:"major_heap_increment" 0 ; - E.int ~comment:"space_overhead" 0; - E.int ~comment:"verbose" 0; (* TODO*) - E.int ~comment:"max_overhead" 0; - E.int ~comment:"stack_limit" 0; - E.int ~comment:"allocation_policy" 0] + Js_of_lam_record.make NA + E.[ + "minor_heap_size", int 0 ; + "major_heap_increment", int 0 ; + "space_overhead", int 0; + "verbose", int 0; (* TODO*) + "max_overhead", int 0; + "stack_limit", int 0; + "allocation_policy", int 0 + ] | "caml_set_oo_id" -> (** ATT: relevant to how exception is encoded in OCaml @@ -411,24 +413,21 @@ let query (prim : Lam_compile_env.primitive_description) less code side when serialzation, and more knowledge in jsir *) - begin match args with - | [ { expression_desc = Array ( - [ tag; str; {expression_desc = J.Number (Int { i = 0; _}); _} ],flag); - _} as v - ] + begin match Js_of_lam_exception.match_exception_def args + with + | Some ( exception_str, mutable_flag) + -> + Js_of_lam_exception.make_exception + (E.prefix_inc + (E.runtime_var_vid + Js_config.builtin_exceptions + "caml_oo_last_id")) + exception_str mutable_flag - {v with expression_desc = - J.Array - ([ tag; str ; - E.prefix_inc - (E.runtime_var_vid - Js_config.builtin_exceptions - "caml_oo_last_id") - ], flag) - } | _ -> - E.runtime_call Js_config.builtin_exceptions prim.prim_name args + E.runtime_call + Js_config.builtin_exceptions prim.prim_name args end | "caml_sys_const_big_endian" -> @@ -448,8 +447,11 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_sys_get_argv" -> (** TODO: refine Inlined here is helpful for DCE + {[ external get_argv: unit -> string * string array = "caml_sys_get_argv" ]} *) - Js_of_lam_tuple.make [E.str "cmd"; E.arr NA [] ] + Js_of_lam_tuple.make [E.str "cmd"; + Js_of_lam_array.make_array NA Pgenarray [] + ] | "caml_sys_time" | "caml_sys_random_seed" @@ -458,9 +460,12 @@ let query (prim : Lam_compile_env.primitive_description) E.runtime_call Js_config.sys prim.prim_name args | "caml_lex_engine" | "caml_new_lex_engine" + -> + E.runtime_call Js_config.lexer prim.prim_name args | "caml_parse_engine" - | "caml_set_parser_trace" -> - E.runtime_call Js_config.lex_parse prim.prim_name args + | "caml_set_parser_trace" + -> + E.runtime_call Js_config.parser prim.prim_name args | "caml_array_sub" | "caml_array_concat" @@ -479,7 +484,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_ml_input_char" -> E.runtime_call Js_config.io prim.prim_name args - + | "caml_update_dummy" | "caml_obj_dup" -> (** Note currently is an Array copy function, this is tightly coupled with how record, tuple encoded in JS. @@ -488,7 +493,7 @@ let query (prim : Lam_compile_env.primitive_description) *) begin match args with - | [ a ] when Js_helper.is_constant a -> a + | [ a ] when Js_analyzer.is_constant a -> a | _ -> E.runtime_call Js_config.obj_runtime prim.prim_name args end @@ -500,22 +505,16 @@ let query (prim : Lam_compile_env.primitive_description) ATTENTION: This optmization is coupled with memory layout *) begin match args with - | [ {expression_desc = Number (Int { i = tag; _}); _ }; - {expression_desc = Number (Int { i = 0;_}); _} ] -> - E.arr Immutable [E.int tag] (** size 0*) - | _ -> - E.runtime_call Js_config.obj_runtime prim.prim_name args - - end - | "caml_obj_is_block" - | "caml_obj_tag" - | "caml_obj_set_tag" + | [ tag; + {expression_desc = Number (Int { i ;_}); _} ] -> + E.make_block tag NA (Ext_list.init i (fun _ -> E.int 0) ) NA + | [ tag; size] -> + E.uninitialized_object tag size + | _ -> assert false - | "caml_obj_truncate" - | "caml_lazy_make_forward" -> - E.runtime_call Js_config.obj_runtime prim.prim_name args + end | "caml_format_float" | "caml_nativeint_format" @@ -535,13 +534,15 @@ let query (prim : Lam_compile_env.primitive_description) end (* "caml_alloc_dummy"; *) (* TODO: "caml_alloc_dummy_float"; *) - | "caml_update_dummy" + + | "caml_obj_is_block" + | "caml_obj_truncate" + | "caml_lazy_make_forward" | "caml_compare" | "caml_int_compare" | "caml_int32_compare" | "caml_nativeint_compare" - | "caml_equal" | "caml_notequal" | "caml_greaterequal" @@ -549,8 +550,19 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_lessequal" | "caml_lessthan" - | "caml_convert_raw_backtrace_slot" + -> + E.runtime_call Js_config.obj_runtime prim.prim_name args + | "caml_obj_set_tag" + -> begin match args with + | [a;b] -> E.set_tag a b + | _ -> assert false end + | "caml_obj_tag" -> + (* Note that in ocaml, [int] has tag [1000] and [string] has tag [252] *) + begin match args with + | [e] -> E.tag e + | _ -> assert false end + | "caml_convert_raw_backtrace_slot" | "caml_bswap16" | "caml_int32_bswap" | "caml_nativeint_bswap" @@ -644,6 +656,11 @@ let query (prim : Lam_compile_env.primitive_description) | [e] -> E.string_of_small_int_array e | _ -> assert false end + | "js_is_instance_array" + -> + begin match args with + | [e] -> E.is_instance_array e + | _ -> assert false end | "js_typeof" -> begin match args with @@ -700,6 +717,23 @@ let query (prim : Lam_compile_env.primitive_description) E.call ~info:{arity=Full} fn rest | _ -> assert false end + | "js_uninitialized_object" + -> + begin match args with + | [ tag; size] -> E.uninitialized_object tag size + | _ -> assert false end + | "js_obj_length" + -> + begin match args with + | [e] -> E.obj_length e + | _ -> assert false + end + | "js_obj_set_length" + -> + begin match args with + | [a; b] -> E.set_length a b + | _ -> assert false + end | _ -> let comment = "Missing primitve" in diff --git a/jscomp/lam_fold.ml b/jscomp/lam_fold.ml index 0765861d70..dd5ee272ba 100644 --- a/jscomp/lam_fold.ml +++ b/jscomp/lam_fold.ml @@ -74,8 +74,8 @@ class virtual fold = * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - (* Author: Hongbo Zhang *) (* Globals *) - (* Operations on heap blocks *) (* Force lazy values *) + (* Author: Hongbo Zhang *) (* exception/ Record labels *) + (* Globals *) (* Operations on heap blocks *) (* Force lazy values *) (* External call *) (* Exceptions *) (* Boolean operations *) (* Integer operations *) (* Float operations *) (* String operations *) (* Array operations *) diff --git a/jscomp/lam_map.ml b/jscomp/lam_map.ml index 133f4f09e1..fe52159f61 100644 --- a/jscomp/lam_map.ml +++ b/jscomp/lam_map.ml @@ -80,8 +80,8 @@ class virtual map = * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - (* Author: Hongbo Zhang *) (* Globals *) - (* Operations on heap blocks *) (* Force lazy values *) + (* Author: Hongbo Zhang *) (* exception/ Record labels *) + (* Globals *) (* Operations on heap blocks *) (* Force lazy values *) (* External call *) (* Exceptions *) (* Boolean operations *) (* Integer operations *) (* Float operations *) (* String operations *) (* Array operations *) diff --git a/jscomp/lam_runtime.ml b/jscomp/lam_runtime.ml index db9442af13..8866099251 100644 --- a/jscomp/lam_runtime.ml +++ b/jscomp/lam_runtime.ml @@ -31,7 +31,7 @@ let builtin_modules = "caml_sys", true; "caml_bigarray", true; "caml_hash", true; - "caml_obj_runtime", true; + "caml_obj", true; "caml_c_ffi", true; "caml_int64", true; "caml_polyfill", true; diff --git a/jscomp/lambda.mlp b/jscomp/lambda.mlp index ae73513d7a..67f80f15c3 100644 --- a/jscomp/lambda.mlp +++ b/jscomp/lambda.mlp @@ -40,7 +40,7 @@ and tag_info = | Array | Variant of string | Record - | NA + | NA (* exception/ Record labels *) and ident = Ident.t and primitive = diff --git a/jscomp/runtime/.depend b/jscomp/runtime/.depend index 6fe8da32a7..a3379da788 100644 --- a/jscomp/runtime/.depend +++ b/jscomp/runtime/.depend @@ -1,5 +1,6 @@ caml_array.cmi : caml_exceptions.cmi : +caml_obj.cmi : caml_oo.cmi : caml_string.cmi : caml_array.cmo : caml_array.cmi @@ -8,6 +9,8 @@ caml_curry.cmo : caml_curry.cmx : caml_exceptions.cmo : caml_exceptions.cmi caml_exceptions.cmx : caml_exceptions.cmi +caml_obj.cmo : caml_obj.cmi +caml_obj.cmx : caml_obj.cmi caml_oo.cmo : caml_oo.cmi caml_oo.cmx : caml_oo.cmi caml_string.cmo : caml_string.cmi @@ -18,6 +21,8 @@ caml_curry.cmo : caml_curry.cmj : caml_exceptions.cmo : caml_exceptions.cmi caml_exceptions.cmj : caml_exceptions.cmi +caml_obj.cmo : caml_obj.cmi +caml_obj.cmj : caml_obj.cmi caml_oo.cmo : caml_oo.cmi caml_oo.cmj : caml_oo.cmi caml_string.cmo : caml_string.cmi diff --git a/jscomp/runtime/Makefile b/jscomp/runtime/Makefile index e14a50440c..2f7595d4b1 100644 --- a/jscomp/runtime/Makefile +++ b/jscomp/runtime/Makefile @@ -5,7 +5,7 @@ CAMLC=../bin/osc SOURCE_LIST := $(shell cat runtime.mllib) RUNTIME := $(addsuffix .cmj, $(SOURCE_LIST)) - +COMPFLAGS := -w -40 -safe-string $(RUNTIME): $(CAMLC) diff --git a/jscomp/runtime/caml_array.js b/jscomp/runtime/caml_array.js index d541f78f71..5402b386d5 100644 --- a/jscomp/runtime/caml_array.js +++ b/jscomp/runtime/caml_array.js @@ -19,8 +19,8 @@ function len(_acc, _l) { var l = _l; var acc = _acc; if (l) { - _l = l[2]; - _acc = l[1].length + acc; + _l = l[1]; + _acc = l[0].length + acc; continue ; } @@ -35,7 +35,7 @@ function fill(arr, _i, _l) { var l = _l; var i = _i; if (l) { - var x = l[1]; + var x = l[0]; var l$1 = x.length; var k = i; var j = 0; @@ -44,7 +44,7 @@ function fill(arr, _i, _l) { ++ k; ++ j; }; - _l = l[2]; + _l = l[1]; _i = k; continue ; diff --git a/jscomp/runtime/caml_exceptions.js b/jscomp/runtime/caml_exceptions.js index 9a8f1c9262..b3c87a6bdd 100644 --- a/jscomp/runtime/caml_exceptions.js +++ b/jscomp/runtime/caml_exceptions.js @@ -5,7 +5,6 @@ var Caml_builtin_exceptions = require("./caml_builtin_exceptions"); function caml_raise_sys_error(msg) { throw [ - 0, Caml_builtin_exceptions.Sys_error, msg ]; @@ -13,7 +12,6 @@ function caml_raise_sys_error(msg) { function caml_failwith(s) { throw [ - 0, Caml_builtin_exceptions.Failure, s ]; @@ -21,7 +19,6 @@ function caml_failwith(s) { function caml_invalid_argument(s) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, s ]; @@ -29,7 +26,6 @@ function caml_invalid_argument(s) { function caml_array_bound_error() { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "index out of bounds" ]; @@ -45,7 +41,6 @@ function caml_raise_not_found() { function caml_undef_module(loc) { throw [ - 0, Caml_builtin_exceptions.Undefined_recursive_module, loc ]; diff --git a/jscomp/runtime/caml_lexer.js b/jscomp/runtime/caml_lexer.js index 7d567b4be7..1822be5c1a 100644 --- a/jscomp/runtime/caml_lexer.js +++ b/jscomp/runtime/caml_lexer.js @@ -29,6 +29,10 @@ var caml_exceptions_1 = require('./caml_exceptions'); function caml_lex_array(s) { var l = s.length / 2; var a = new Array(l); + // when s.charCodeAt(2 * i + 1 ) > 128 (0x80) + // a[i] < 0 + // for(var i = 0 ; i <= 0xffff; ++i) { if (i << 16 >> 16 !==i){console.log(i<<16>>16, 'vs',i)}} + // for (var i = 0; i < l; i++) a[i] = (s.charCodeAt(2 * i) | (s.charCodeAt(2 * i + 1) << 8)) << 16 >> 16; return a; @@ -70,18 +74,20 @@ function caml_lex_array(s) { * @returns {any} */ function caml_lex_engine(tbl, start_state, lexbuf) { - var lex_buffer = 2; - var lex_buffer_len = 3; - var lex_start_pos = 5; - var lex_curr_pos = 6; - var lex_last_pos = 7; - var lex_last_action = 8; - var lex_eof_reached = 9; - var lex_base = 1; - var lex_backtrk = 2; - var lex_default = 3; - var lex_trans = 4; - var lex_check = 5; + // Lexing.lexbuf + var lex_buffer = 1; + var lex_buffer_len = 2; + var lex_start_pos = 4; + var lex_curr_pos = 5; + var lex_last_pos = 6; + var lex_last_action = 7; + var lex_eof_reached = 8; + // Lexing.lex_tables + var lex_base = 0; + var lex_backtrk = 1; + var lex_default = 2; + var lex_trans = 3; + var lex_check = 4; if (!tbl.lex_default) { tbl.lex_base = caml_lex_array(tbl[lex_base]); tbl.lex_backtrk = caml_lex_array(tbl[lex_backtrk]); @@ -189,25 +195,27 @@ function caml_lex_run_tag(s, i, mem) { * @returns {any} */ function caml_new_lex_engine(tbl, start_state, lexbuf) { - var lex_buffer = 2; - var lex_buffer_len = 3; - var lex_start_pos = 5; - var lex_curr_pos = 6; - var lex_last_pos = 7; - var lex_last_action = 8; - var lex_eof_reached = 9; - var lex_mem = 10; - var lex_base = 1; - var lex_backtrk = 2; - var lex_default = 3; - var lex_trans = 4; - var lex_check = 5; - var lex_base_code = 6; - var lex_backtrk_code = 7; - var lex_default_code = 8; - var lex_trans_code = 9; - var lex_check_code = 10; - var lex_code = 11; + // Lexing.lexbuf + var lex_buffer = 1; + var lex_buffer_len = 2; + var lex_start_pos = 4; + var lex_curr_pos = 5; + var lex_last_pos = 6; + var lex_last_action = 7; + var lex_eof_reached = 8; + var lex_mem = 9; + // Lexing.lex_tables + var lex_base = 0; + var lex_backtrk = 1; + var lex_default = 2; + var lex_trans = 3; + var lex_check = 4; + var lex_base_code = 5; + var lex_backtrk_code = 6; + var lex_default_code = 7; + var lex_trans_code = 8; + var lex_check_code = 9; + var lex_code = 10; if (!tbl.lex_default) { tbl.lex_base = caml_lex_array(tbl[lex_base]); tbl.lex_backtrk = caml_lex_array(tbl[lex_backtrk]); @@ -298,321 +306,3 @@ function caml_new_lex_engine(tbl, start_state, lexbuf) { } } exports.caml_new_lex_engine = caml_new_lex_engine; -/** - * Note that TS enum is not friendly to Closure compiler - * @enum{number} - */ -var Automata = { - START: 0, - LOOP: 6, - TOKEN_READ: 1, - TEST_SHIFT: 7, - ERROR_DETECTED: 5, - SHIFT: 8, - SHIFT_RECOVER: 9, - STACK_GROWN_1: 2, - REDUCE: 10, - STACK_GROWN_2: 3, - SEMANTIC_ACTION_COMPUTED: 4 -}; -/** - * @enum{number} - */ -var Result = { - READ_TOKEN: 0, - RAISE_PARSE_ERROR: 1, - GROW_STACKS_1: 2, - GROW_STACKS_2: 3, - COMPUTE_SEMANTIC_ACTION: 4, - CALL_ERROR_FUNCTION: 5 -}; -var PARSER_TRACE = false; -/** - * external parse_engine : parse_tables -> parser_env -> parser_input -> Obj.t -> parser_output - * parsing.ml - * - * type parse_tables = { - * actions : (parser_env -> Obj.t) array - * transl_const : int array; - * transl_block : int array; - * lhs : string; - * len : string; - * defred : string; - * dgoto : string; - * sindex : string; - * rindex : string; - * gindex : string; - * tablesize : int; - * table : string; - * check : string; - * error_function : string -> unit; - * names_const : string; - * names_block : string - * } - * - * type parser_env = - * { mutable s_stack : int array; (* States *) - * mutable v_stack : Obj.t array; (* Semantic attributes *) - * mutable symb_start_stack : position array; (* Start positions *) - * mutable symb_end_stack : position array; (* End positions *) - * mutable stacksize : int; (* Size of the stacks *) - * mutable stackbase : int; (* Base sp for current parse *) - * mutable curr_char : int; (* Last token read *) - * mutable lval : Obj.t; (* Its semantic attribute *) - * mutable symb_start : position; (* Start pos. of the current symbol*) - * mutable symb_end : position; (* End pos. of the current symbol *) - * mutable asp : int; (* The stack pointer for attributes *) - * mutable rule_len : int; (* Number of rhs items in the rule *) - * mutable rule_number : int; (* Rule number to reduce by *) - * mutable sp : int; (* Saved sp for parse_engine *) - * mutable state : int; (* Saved state for parse_engine *) - * mutable errflag : int } (* Saved error flag for parse_engine *) - * - * type parser_input = - * | Start - * | Token_read - * | Stacks_grown_1 - * | Stacks_grown_2 - * | Semantic_action_computed - * | Error_detected - - * @param tables - * @param env - * @param cmd - * @param arg - * @returns {number} - */ -function caml_parse_engine(tables, env, cmd, arg) { - var ERRCODE = 256; - //var START = 0; - //var TOKEN_READ = 1; - //var STACKS_GROWN_1 = 2; - //var STACKS_GROWN_2 = 3; - //var SEMANTIC_ACTION_COMPUTED = 4; - //var ERROR_DETECTED = 5; - //var loop = 6; - //var testshift = 7; - //var shift = 8; - //var shift_recover = 9; - //var reduce = 10; - var env_s_stack = 1; // array - var env_v_stack = 2; // array - var env_symb_start_stack = 3; // array - var env_symb_end_stack = 4; // array - var env_stacksize = 5; - var env_stackbase = 6; - var env_curr_char = 7; - var env_lval = 8; - var env_symb_start = 9; - var env_symb_end = 10; - var env_asp = 11; - var env_rule_len = 12; - var env_rule_number = 13; - var env_sp = 14; - var env_state = 15; - var env_errflag = 16; - // var _tbl_actions = 1; - var tbl_transl_const = 2; // array - var tbl_transl_block = 3; // array - var tbl_lhs = 4; - var tbl_len = 5; - var tbl_defred = 6; - var tbl_dgoto = 7; - var tbl_sindex = 8; - var tbl_rindex = 9; - var tbl_gindex = 10; - var tbl_tablesize = 11; - var tbl_table = 12; - var tbl_check = 13; - // var _tbl_error_function = 14; - // var _tbl_names_const = 15; - // var _tbl_names_block = 16; - if (!tables.dgoto) { - tables.defred = caml_lex_array(tables[tbl_defred]); - tables.sindex = caml_lex_array(tables[tbl_sindex]); - tables.check = caml_lex_array(tables[tbl_check]); - tables.rindex = caml_lex_array(tables[tbl_rindex]); - tables.table = caml_lex_array(tables[tbl_table]); - tables.len = caml_lex_array(tables[tbl_len]); - tables.lhs = caml_lex_array(tables[tbl_lhs]); - tables.gindex = caml_lex_array(tables[tbl_gindex]); - tables.dgoto = caml_lex_array(tables[tbl_dgoto]); - } - var res; - var n, n1, n2, state1; - // RESTORE - var sp = env[env_sp]; - var state = env[env_state]; - var errflag = env[env_errflag]; - exit: for (;;) { - //console.error("State", Automata[cmd]); - switch (cmd) { - case Automata.START: - state = 0; - errflag = 0; - // Fall through - case Automata.LOOP: - n = tables.defred[state]; - if (n != 0) { - cmd = Automata.REDUCE; - break; - } - if (env[env_curr_char] >= 0) { - cmd = Automata.TEST_SHIFT; - break; - } - res = Result.READ_TOKEN; - break exit; - /* The ML code calls the lexer and updates */ - /* symb_start and symb_end */ - case Automata.TOKEN_READ: - if (arg instanceof Array) { - env[env_curr_char] = tables[tbl_transl_block][arg[0] /* + 1 */]; - env[env_lval] = arg[1]; - } - else { - env[env_curr_char] = tables[tbl_transl_const][arg /* + 1 */]; - env[env_lval] = 0; - } - if (PARSER_TRACE) { - console.error("State %d, read token", state, arg); - } - // Fall through - case Automata.TEST_SHIFT: - n1 = tables.sindex[state]; - n2 = n1 + env[env_curr_char]; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == env[env_curr_char]) { - cmd = Automata.SHIFT; - break; - } - n1 = tables.rindex[state]; - n2 = n1 + env[env_curr_char]; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == env[env_curr_char]) { - n = tables.table[n2]; - cmd = Automata.REDUCE; - break; - } - if (errflag <= 0) { - res = Result.CALL_ERROR_FUNCTION; - break exit; - } - // Fall through - /* The ML code calls the error function */ - case Automata.ERROR_DETECTED: - if (errflag < 3) { - errflag = 3; - for (;;) { - state1 = env[env_s_stack][sp /* + 1*/]; - n1 = tables.sindex[state1]; - n2 = n1 + ERRCODE; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == ERRCODE) { - cmd = Automata.SHIFT_RECOVER; - break; - } - else { - if (sp <= env[env_stackbase]) - return Result.RAISE_PARSE_ERROR; - /* The ML code raises Parse_error */ - sp--; - } - } - } - else { - if (env[env_curr_char] == 0) - return Result.RAISE_PARSE_ERROR; - /* The ML code raises Parse_error */ - env[env_curr_char] = -1; - cmd = Automata.LOOP; - break; - } - // Fall through - case Automata.SHIFT: - env[env_curr_char] = -1; - if (errflag > 0) - errflag--; - // Fall through - case Automata.SHIFT_RECOVER: - if (PARSER_TRACE) { - console.error("State %d: shift to state %d", state, tables.table[n2]); - } - state = tables.table[n2]; - sp++; - if (sp >= env[env_stacksize]) { - res = Result.GROW_STACKS_1; - break exit; - } - // Fall through - /* The ML code resizes the stacks */ - case Automata.STACK_GROWN_1: - env[env_s_stack][sp /* + 1 */] = state; - env[env_v_stack][sp /* + 1 */] = env[env_lval]; - env[env_symb_start_stack][sp /* + 1 */] = env[env_symb_start]; - env[env_symb_end_stack][sp /* + 1 */] = env[env_symb_end]; - cmd = Automata.LOOP; - break; - case Automata.REDUCE: - if (PARSER_TRACE) { - console.error("State %d : reduce by rule %d", state, n); - } - var m = tables.len[n]; - env[env_asp] = sp; - env[env_rule_number] = n; - env[env_rule_len] = m; - sp = sp - m + 1; - m = tables.lhs[n]; - state1 = env[env_s_stack][sp - 1]; // - n1 = tables.gindex[m]; - n2 = n1 + state1; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == state1) - state = tables.table[n2]; - else - state = tables.dgoto[m]; - if (sp >= env[env_stacksize]) { - res = Result.GROW_STACKS_2; - break exit; - } - // Fall through - /* The ML code resizes the stacks */ - case Automata.STACK_GROWN_2: - res = Result.COMPUTE_SEMANTIC_ACTION; - break exit; - /* The ML code calls the semantic action */ - case Automata.SEMANTIC_ACTION_COMPUTED: - env[env_s_stack][sp /* + 1 */] = state; - env[env_v_stack][sp /* + 1*/] = arg; - var asp = env[env_asp]; - env[env_symb_end_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /* + 1*/]; - if (sp > asp) { - /* This is an epsilon production. Take symb_start equal to symb_end. */ - env[env_symb_start_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /*+ 1*/]; - } - cmd = Automata.LOOP; - break; - /* Should not happen */ - default: - return Result.RAISE_PARSE_ERROR; - } - } - // SAVE - env[env_sp] = sp; - env[env_state] = state; - env[env_errflag] = errflag; - return res; -} -exports.caml_parse_engine = caml_parse_engine; -/** - * external set_trace: bool -> bool = "caml_set_parser_trace" - * parsing.ml - * @param {boolean} - * @returns {boolean} - */ -function caml_set_parser_trace(v) { - var old = PARSER_TRACE; - PARSER_TRACE = v; - return old; -} -exports.caml_set_parser_trace = caml_set_parser_trace; diff --git a/jscomp/runtime/caml_lexer.ts b/jscomp/runtime/caml_lexer.ts index 7298886052..84cfffece2 100644 --- a/jscomp/runtime/caml_lexer.ts +++ b/jscomp/runtime/caml_lexer.ts @@ -33,6 +33,10 @@ import {caml_failwith} from './caml_exceptions' function caml_lex_array(s : string) { var l = s.length / 2; var a = new Array(l); + // when s.charCodeAt(2 * i + 1 ) > 128 (0x80) + // a[i] < 0 + // for(var i = 0 ; i <= 0xffff; ++i) { if (i << 16 >> 16 !==i){console.log(i<<16>>16, 'vs',i)}} + // for (var i = 0; i < l; i++) a[i] = (s.charCodeAt(2 * i) | (s.charCodeAt(2 * i + 1) << 8)) << 16 >> 16; return a; @@ -75,18 +79,22 @@ function caml_lex_array(s : string) { * @returns {any} */ function caml_lex_engine(tbl, start_state : number, lexbuf) : number { - var lex_buffer = 2; - var lex_buffer_len = 3; - var lex_start_pos = 5; - var lex_curr_pos = 6; - var lex_last_pos = 7; - var lex_last_action = 8; - var lex_eof_reached = 9; - var lex_base = 1; - var lex_backtrk = 2; - var lex_default = 3; - var lex_trans = 4; - var lex_check = 5; + + // Lexing.lexbuf + var lex_buffer = 1; + var lex_buffer_len = 2; + var lex_start_pos = 4; + var lex_curr_pos = 5; + var lex_last_pos = 6; + var lex_last_action = 7; + var lex_eof_reached = 8; + + // Lexing.lex_tables + var lex_base = 0; + var lex_backtrk = 1; + var lex_default = 2; + var lex_trans = 3; + var lex_check = 4; if (!tbl.lex_default) { tbl.lex_base = caml_lex_array (tbl[lex_base]); @@ -189,25 +197,29 @@ function caml_lex_run_tag(s, i, mem) { * @returns {any} */ function caml_new_lex_engine(tbl, start_state, lexbuf) { - var lex_buffer = 2; - var lex_buffer_len = 3; - var lex_start_pos = 5; - var lex_curr_pos = 6; - var lex_last_pos = 7; - var lex_last_action = 8; - var lex_eof_reached = 9; - var lex_mem = 10; - var lex_base = 1; - var lex_backtrk = 2; - var lex_default = 3; - var lex_trans = 4; - var lex_check = 5; - var lex_base_code = 6; - var lex_backtrk_code = 7; - var lex_default_code = 8; - var lex_trans_code = 9; - var lex_check_code = 10; - var lex_code = 11; + + // Lexing.lexbuf + var lex_buffer =1; + var lex_buffer_len = 2; + var lex_start_pos = 4; + var lex_curr_pos = 5; + var lex_last_pos = 6; + var lex_last_action = 7; + var lex_eof_reached = 8; + var lex_mem = 9; + + // Lexing.lex_tables + var lex_base = 0; + var lex_backtrk = 1; + var lex_default = 2; + var lex_trans = 3; + var lex_check = 4; + var lex_base_code = 5; + var lex_backtrk_code = 6; + var lex_default_code = 7; + var lex_trans_code = 8; + var lex_check_code = 9; + var lex_code = 10; if (!tbl.lex_default) { tbl.lex_base = caml_lex_array (tbl[lex_base]); @@ -299,331 +311,8 @@ function caml_new_lex_engine(tbl, start_state, lexbuf) { } } -/** - * Note that TS enum is not friendly to Closure compiler - * @enum{number} - */ -var Automata = { - START : 0, - LOOP : 6, - TOKEN_READ : 1, - TEST_SHIFT : 7, - ERROR_DETECTED : 5, - SHIFT : 8, - SHIFT_RECOVER : 9, - STACK_GROWN_1 : 2, - REDUCE : 10, - STACK_GROWN_2 : 3, - SEMANTIC_ACTION_COMPUTED : 4 -} -/** - * @enum{number} - */ -var Result = { - READ_TOKEN : 0, - RAISE_PARSE_ERROR : 1, - GROW_STACKS_1 : 2, - GROW_STACKS_2 : 3, - COMPUTE_SEMANTIC_ACTION : 4, - CALL_ERROR_FUNCTION : 5 -} - -var PARSER_TRACE = false; - -/** - * external parse_engine : parse_tables -> parser_env -> parser_input -> Obj.t -> parser_output - * parsing.ml - * - * type parse_tables = { - * actions : (parser_env -> Obj.t) array - * transl_const : int array; - * transl_block : int array; - * lhs : string; - * len : string; - * defred : string; - * dgoto : string; - * sindex : string; - * rindex : string; - * gindex : string; - * tablesize : int; - * table : string; - * check : string; - * error_function : string -> unit; - * names_const : string; - * names_block : string - * } - * - * type parser_env = - * { mutable s_stack : int array; (* States *) - * mutable v_stack : Obj.t array; (* Semantic attributes *) - * mutable symb_start_stack : position array; (* Start positions *) - * mutable symb_end_stack : position array; (* End positions *) - * mutable stacksize : int; (* Size of the stacks *) - * mutable stackbase : int; (* Base sp for current parse *) - * mutable curr_char : int; (* Last token read *) - * mutable lval : Obj.t; (* Its semantic attribute *) - * mutable symb_start : position; (* Start pos. of the current symbol*) - * mutable symb_end : position; (* End pos. of the current symbol *) - * mutable asp : int; (* The stack pointer for attributes *) - * mutable rule_len : int; (* Number of rhs items in the rule *) - * mutable rule_number : int; (* Rule number to reduce by *) - * mutable sp : int; (* Saved sp for parse_engine *) - * mutable state : int; (* Saved state for parse_engine *) - * mutable errflag : int } (* Saved error flag for parse_engine *) - * - * type parser_input = - * | Start - * | Token_read - * | Stacks_grown_1 - * | Stacks_grown_2 - * | Semantic_action_computed - * | Error_detected - - * @param tables - * @param env - * @param cmd - * @param arg - * @returns {number} - */ -function caml_parse_engine(tables, env, cmd, arg) -{ - var ERRCODE = 256; - - //var START = 0; - //var TOKEN_READ = 1; - //var STACKS_GROWN_1 = 2; - //var STACKS_GROWN_2 = 3; - //var SEMANTIC_ACTION_COMPUTED = 4; - //var ERROR_DETECTED = 5; - //var loop = 6; - //var testshift = 7; - //var shift = 8; - //var shift_recover = 9; - //var reduce = 10; - - - - var env_s_stack = 1; // array - var env_v_stack = 2; // array - var env_symb_start_stack = 3; // array - var env_symb_end_stack = 4; // array - var env_stacksize = 5; - var env_stackbase = 6; - var env_curr_char = 7; - var env_lval = 8; - var env_symb_start = 9; - var env_symb_end = 10; - var env_asp = 11; - var env_rule_len = 12; - var env_rule_number = 13; - var env_sp = 14; - var env_state = 15; - var env_errflag = 16; - - // var _tbl_actions = 1; - var tbl_transl_const = 2; // array - var tbl_transl_block = 3; // array - var tbl_lhs = 4; - var tbl_len = 5; - var tbl_defred = 6; - var tbl_dgoto = 7; - var tbl_sindex = 8; - var tbl_rindex = 9; - var tbl_gindex = 10; - var tbl_tablesize = 11; - var tbl_table = 12; - var tbl_check = 13; - // var _tbl_error_function = 14; - // var _tbl_names_const = 15; - // var _tbl_names_block = 16; - - if (!tables.dgoto) { - tables.defred = caml_lex_array (tables[tbl_defred]); - tables.sindex = caml_lex_array (tables[tbl_sindex]); - tables.check = caml_lex_array (tables[tbl_check]); - tables.rindex = caml_lex_array (tables[tbl_rindex]); - tables.table = caml_lex_array (tables[tbl_table]); - tables.len = caml_lex_array (tables[tbl_len]); - tables.lhs = caml_lex_array (tables[tbl_lhs]); - tables.gindex = caml_lex_array (tables[tbl_gindex]); - tables.dgoto = caml_lex_array (tables[tbl_dgoto]); - } - - var res; - var n, n1, n2, state1; - - // RESTORE - var sp = env[env_sp]; - var state = env[env_state]; - var errflag = env[env_errflag]; - - exit:for (;;) { - //console.error("State", Automata[cmd]); - - switch(cmd) { - case Automata.START://START: - state = 0; - errflag = 0; - // Fall through - - case Automata.LOOP://loop: - n = tables.defred[state]; - if (n != 0) { cmd = Automata.REDUCE; break; } - if (env[env_curr_char] >= 0) { cmd = Automata.TEST_SHIFT; break; } - res = Result.READ_TOKEN; - break exit; - /* The ML code calls the lexer and updates */ - /* symb_start and symb_end */ - case Automata.TOKEN_READ://TOKEN_READ: - if (arg instanceof Array) { - env[env_curr_char] = tables[tbl_transl_block][arg[0] /* + 1 */]; - env[env_lval] = arg[1]; - } else { - env[env_curr_char] = tables[tbl_transl_const][arg /* + 1 */]; - env[env_lval] = 0; - } - if(PARSER_TRACE){ - console.error("State %d, read token", state, arg) - } - // Fall through - - case Automata.TEST_SHIFT://testshift: - n1 = tables.sindex[state]; - n2 = n1 + env[env_curr_char]; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == env[env_curr_char]) { - cmd = Automata.SHIFT; break; - } - n1 = tables.rindex[state]; - n2 = n1 + env[env_curr_char]; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == env[env_curr_char]) { - n = tables.table[n2]; - cmd = Automata.REDUCE; break; - } - if (errflag <= 0) { - - res = Result.CALL_ERROR_FUNCTION; - break exit; - } - // Fall through - /* The ML code calls the error function */ - case Automata.ERROR_DETECTED://ERROR_DETECTED: - if (errflag < 3) { - errflag = 3; - for (;;) { - state1 = env[env_s_stack][sp /* + 1*/]; - n1 = tables.sindex[state1]; - n2 = n1 + ERRCODE; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == ERRCODE) { - cmd = Automata.SHIFT_RECOVER; break; - } else { - if (sp <= env[env_stackbase]) return Result.RAISE_PARSE_ERROR; - /* The ML code raises Parse_error */ - sp--; - } - } - } else { - if (env[env_curr_char] == 0) return Result.RAISE_PARSE_ERROR; - /* The ML code raises Parse_error */ - env[env_curr_char] = -1; - cmd = Automata.LOOP; break; - } - // Fall through - case Automata.SHIFT://shift: - env[env_curr_char] = -1; - if (errflag > 0) errflag--; - // Fall through - case Automata.SHIFT_RECOVER://shift_recover: - if(PARSER_TRACE) { - console.error("State %d: shift to state %d", state, tables.table[n2]) - } - state = tables.table[n2]; - sp++; - if (sp >= env[env_stacksize]) { - res = Result.GROW_STACKS_1; - break exit; - } - // Fall through - /* The ML code resizes the stacks */ - case Automata.STACK_GROWN_1: - env[env_s_stack][sp /* + 1 */] = state; - env[env_v_stack][sp /* + 1 */] = env[env_lval]; - env[env_symb_start_stack][sp /* + 1 */] = env[env_symb_start]; - env[env_symb_end_stack][sp /* + 1 */] = env[env_symb_end]; - cmd = Automata.LOOP; - break; - - case Automata.REDUCE: - if(PARSER_TRACE) { - console.error("State %d : reduce by rule %d", state, n) - } - var m = tables.len[n]; - env[env_asp] = sp; - env[env_rule_number] = n; - env[env_rule_len] = m; - sp = sp - m + 1; - m = tables.lhs[n]; - state1 = env[env_s_stack][sp - 1]; // - - n1 = tables.gindex[m]; - n2 = n1 + state1; - if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && - tables.check[n2] == state1) - state = tables.table[n2]; - else - state = tables.dgoto[m]; - if (sp >= env[env_stacksize]) { - res = Result.GROW_STACKS_2; - break exit; - } - // Fall through - /* The ML code resizes the stacks */ - case Automata.STACK_GROWN_2://STACKS_GROWN_2: - res = Result.COMPUTE_SEMANTIC_ACTION; - break exit; - /* The ML code calls the semantic action */ - case Automata.SEMANTIC_ACTION_COMPUTED://SEMANTIC_ACTION_COMPUTED: - env[env_s_stack][sp /* + 1 */] = state; - env[env_v_stack][sp /* + 1*/] = arg; - var asp = env[env_asp]; - env[env_symb_end_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /* + 1*/]; - if (sp > asp) { - /* This is an epsilon production. Take symb_start equal to symb_end. */ - env[env_symb_start_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /*+ 1*/]; - } - cmd = Automata.LOOP; break; - /* Should not happen */ - default: - return Result.RAISE_PARSE_ERROR; - } - } - // SAVE - env[env_sp] = sp; - env[env_state] = state; - env[env_errflag] = errflag; - - return res; -} - - - -/** - * external set_trace: bool -> bool = "caml_set_parser_trace" - * parsing.ml - * @param {boolean} - * @returns {boolean} - */ -function caml_set_parser_trace(v : boolean) { - var old = PARSER_TRACE; - PARSER_TRACE = v; - return old; -} export { caml_lex_engine, caml_new_lex_engine, - caml_parse_engine, - caml_set_parser_trace } \ No newline at end of file diff --git a/jscomp/runtime/caml_obj.d.ts b/jscomp/runtime/caml_obj.d.ts new file mode 100644 index 0000000000..6a08960a8c --- /dev/null +++ b/jscomp/runtime/caml_obj.d.ts @@ -0,0 +1,16 @@ +export var caml_obj_dup: (x : any) => any ; +export var caml_obj_truncate: (x : any, new_size : any) => any ; +export var caml_obj_is_block: (x : any) => any ; +export var caml_lazy_make_forward: (x : any) => any ; +export var caml_update_dummy: (x : any, y : any) => any ; +export var caml_int_compare: (x : any, y : any) => any ; +export var caml_int32_compare: (x : any, y : any) => any ; +export var caml_nativeint_compare: (x : any, y : any) => any ; +export var caml_compare: (a : any, b : any) => any ; +export var caml_equal: (a : any, b : any) => any ; +export var caml_notequal: (a : any, b : any) => any ; +export var caml_greaterequal: (a : any, b : any) => any ; +export var caml_greaterthan: (a : any, b : any) => any ; +export var caml_lessthan: (a : any, b : any) => any ; +export var caml_lessequal: (a : any, b : any) => any ; + diff --git a/jscomp/runtime/caml_obj.js b/jscomp/runtime/caml_obj.js new file mode 100644 index 0000000000..8cb0815b02 --- /dev/null +++ b/jscomp/runtime/caml_obj.js @@ -0,0 +1,304 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_builtin_exceptions = require("./caml_builtin_exceptions"); + +function caml_obj_dup(x) { + var len = x.length; + var v = { + length: len, + tag: x.tag | 0 + }; + for(var i = 0 ,i_finish = len - 1; i<= i_finish; ++i){ + v[i] = v[i]; + } + return v; +} + +function caml_obj_truncate(x, new_size) { + var len = x.length; + if (new_size <= 0 || new_size > len) { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "Obj.truncate" + ]; + } + else if (len !== new_size) { + for(var i = new_size ,i_finish = len - 1; i<= i_finish; ++i){ + x[i] = 0; + } + x.length = new_size; + return /* () */0; + } + else { + return 0; + } +} + +function caml_obj_is_block(x) { + return +(typeof x.length === "undefined"); +} + +function caml_lazy_make_forward(x) { + return { + 0: x, + length: 1, + tag: 250 + }; +} + +function caml_update_dummy(x, y) { + var len = y.length; + for(var i = 0 ,i_finish = len - 1; i<= i_finish; ++i){ + x[i] = y[i]; + } + x.tag = y.tag | 0; + x.length = y.length; + return /* () */0; +} + +function caml_int_compare(x, y) { + if (x < y) { + return -1; + } + else if (x === y) { + return 0; + } + else { + return 1; + } +} + +function caml_compare(_a, _b) { + while(true) { + var b = _b; + var a = _a; + if (typeof a === "string") { + var x = a; + var y = b; + if (x < y) { + return -1; + } + else if (x === y) { + return 0; + } + else { + return 1; + } + } + else if (typeof a === "number") { + return caml_int_compare(a, b); + } + else { + var tag_a = a.tag | 0; + var tag_b = b.tag | 0; + if (tag_a === 250) { + _a = a[0]; + continue ; + + } + else if (tag_b === 250) { + _b = b[0]; + continue ; + + } + else if (tag_a === 248) { + return caml_int_compare(a[1], b[1]); + } + else if (tag_a === 251) { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "equal: abstract value" + ]; + } + else if (tag_a !== tag_b) { + if (tag_a < tag_b) { + return -1; + } + else { + return 1; + } + } + else { + var len_a = a.length; + var len_b = b.length; + if (len_a === len_b) { + var a$1 = a; + var b$1 = b; + var _i = 0; + var same_length = len_a; + while(true) { + var i = _i; + if (i === same_length) { + return 0; + } + else { + var res = caml_compare(a$1[i], b$1[i]); + if (res !== 0) { + return res; + } + else { + _i = i + 1; + continue ; + + } + } + }; + } + else if (len_a < len_b) { + var a$2 = a; + var b$2 = b; + var _i$1 = 0; + var short_length = len_a; + while(true) { + var i$1 = _i$1; + if (i$1 === short_length) { + return -1; + } + else { + var res$1 = caml_compare(a$2[i$1], b$2[i$1]); + if (res$1 !== 0) { + return res$1; + } + else { + _i$1 = i$1 + 1; + continue ; + + } + } + }; + } + else { + var a$3 = a; + var b$3 = b; + var _i$2 = 0; + var short_length$1 = len_b; + while(true) { + var i$2 = _i$2; + if (i$2 === short_length$1) { + return 1; + } + else { + var res$2 = caml_compare(a$3[i$2], b$3[i$2]); + if (res$2 !== 0) { + return res$2; + } + else { + _i$2 = i$2 + 1; + continue ; + + } + } + }; + } + } + } + }; +} + +function caml_equal(_a, _b) { + while(true) { + var b = _b; + var a = _a; + if (typeof a === "string") { + return +(a === b); + } + else if (typeof a === "number") { + return +(a === b); + } + else { + var tag_a = a.tag | 0; + var tag_b = b.tag | 0; + if (tag_a === 250) { + _a = a[0]; + continue ; + + } + else if (tag_b === 250) { + _b = b[0]; + continue ; + + } + else if (tag_a === 248) { + return +(a[1] === b[1]); + } + else if (tag_a === 251) { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "equal: abstract value" + ]; + } + else if (tag_a !== tag_b) { + return /* false */0; + } + else { + var len_a = a.length; + var len_b = b.length; + if (len_a === len_b) { + var a$1 = a; + var b$1 = b; + var _i = 0; + var same_length = len_a; + while(true) { + var i = _i; + if (i === same_length) { + return /* true */1; + } + else if (caml_equal(a$1[i], b$1[i])) { + _i = i + 1; + continue ; + + } + else { + return /* false */0; + } + }; + } + else { + return /* false */0; + } + } + } + }; +} + +function caml_notequal(a, b) { + return !caml_equal(a, b); +} + +function caml_greaterequal(a, b) { + return +(caml_compare(a, b) >= 0); +} + +function caml_greaterthan(a, b) { + return +(caml_compare(a, b) > 0); +} + +function caml_lessequal(a, b) { + return +(caml_compare(a, b) <= 0); +} + +function caml_lessthan(a, b) { + return +(caml_compare(a, b) < 0); +} + +var caml_int32_compare = caml_int_compare; + +var caml_nativeint_compare = caml_int_compare; + +exports.caml_obj_dup = caml_obj_dup; +exports.caml_obj_truncate = caml_obj_truncate; +exports.caml_obj_is_block = caml_obj_is_block; +exports.caml_lazy_make_forward = caml_lazy_make_forward; +exports.caml_update_dummy = caml_update_dummy; +exports.caml_int_compare = caml_int_compare; +exports.caml_int32_compare = caml_int32_compare; +exports.caml_nativeint_compare = caml_nativeint_compare; +exports.caml_compare = caml_compare; +exports.caml_equal = caml_equal; +exports.caml_notequal = caml_notequal; +exports.caml_greaterequal = caml_greaterequal; +exports.caml_greaterthan = caml_greaterthan; +exports.caml_lessthan = caml_lessthan; +exports.caml_lessequal = caml_lessequal; +/* No side effect */ diff --git a/jscomp/runtime/caml_obj.ml b/jscomp/runtime/caml_obj.ml new file mode 100644 index 0000000000..f0ff70d468 --- /dev/null +++ b/jscomp/runtime/caml_obj.ml @@ -0,0 +1,203 @@ +(* OCamlScript compiler + * Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +(* Author: Hongbo Zhang *) + + +external caml_obj_set_tag : Obj.t -> int -> unit = "caml_obj_set_tag" +external js_obj_set_length : Obj.t -> int -> unit = "js_obj_set_length" +external js_obj_length : Obj.t -> int = "js_obj_length" +external caml_obj_tag : Obj.t -> int = "caml_obj_tag" +external caml_obj_set_tag : Obj.t -> int -> unit = "caml_obj_set_tag" +external js_uninitialized_object : int -> int -> Obj.t = "js_uninitialized_object" +external js_is_instance_array : Obj.t -> bool = "js_is_instance_array" +external js_typeof : 'a -> string = "js_typeof" + +(** Mainly used in camlinternalOO + {[ + let dummy_met : item = obj (Obj.new_block 0 0) + let obj = Obj.new_block Obj.object_tag table.size + ]} + + Here we only need generate expression like this + {[ + { tag : tag ; length : size } + ]} + we don't need fill fields, since it is not required by GC +*) +let caml_obj_dup (x : Obj.t) = + let len = js_obj_length x in + let v = js_uninitialized_object (caml_obj_tag x ) len in + for i = 0 to len - 1 do + Obj.set_field v i (Obj.field v i) + done; + v + +let caml_obj_truncate (x : Obj.t) (new_size : int) = + let len = js_obj_length x in + if new_size <= 0 || new_size > len then + raise (Invalid_argument "Obj.truncate") + else + if len != new_size then + begin + for i = new_size to len - 1 do + Obj.set_field x i (Obj.magic 0) + done; + js_obj_set_length x new_size + end + + +let caml_obj_is_block x = + js_typeof (Obj.repr (js_obj_length x )) = "undefined" + +let caml_lazy_make_forward x = lazy x + +(** TODO: the dummy one should be [{}] *) +let caml_update_dummy x y = + let len = js_obj_length y in + for i = 0 to len - 1 do + Obj.set_field x i (Obj.field y i) + done ; + Obj.set_tag x (Obj.tag y); + js_obj_set_length x (js_obj_length y) + +let caml_int_compare (x : int) (y: int) : int = + if x < y then -1 else if x = y then 0 else 1 + +let caml_string_compare (x : string) (y: string) : int = + if x < y then -1 else if x = y then 0 else 1 + +(** TODO: investigate total + [compare x y] returns [0] if [x] is equal to [y], + a negative integer if [x] is less than [y], + and a positive integer if [x] is greater than [y]. + The ordering implemented by compare is compatible with the comparison + predicates [=], [<] and [>] defined above, with one difference on the treatment of the float value + [nan]. + + Namely, the comparison predicates treat nan as different from any other float value, + including itself; while compare treats [nan] as equal to itself and less than any other float value. + This treatment of [nan] ensures that compare defines a total ordering relation. + compare applied to functional values may raise Invalid_argument. compare applied to cyclic structures + may not terminate. + + The compare function can be used as the comparison function required by the [Set.Make] and [Map.Make] functors, + as well as the [List.sort] and [Array.sort] functions. +*) +let rec caml_compare (a : Obj.t) (b : Obj.t) : int = + if js_typeof a = "string" then + caml_string_compare (Obj.magic a) (Obj.magic b ) + else if js_typeof a = "number" then + caml_int_compare (Obj.magic a) (Obj.magic b ) + else + (* if js_is_instance_array a then *) + (* 0 *) + (* else *) + let tag_a = caml_obj_tag a in + let tag_b = caml_obj_tag b in + (* double_array_tag: 254 + forward_tag:250 + *) + if tag_a = 250 then + caml_compare (Obj.field a 0) b + else if tag_b = 250 then + caml_compare a (Obj.field b 0) + else if tag_a = 248 (* object/exception *) then + caml_int_compare (Obj.magic @@ Obj.field a 1) (Obj.magic @@ Obj.field b 1 ) + else if tag_a = 251 (* abstract_tag *) then + raise (Invalid_argument "equal: abstract value") + else if tag_a != tag_b then + if tag_a < tag_b then (-1) else 1 + else + let len_a = js_obj_length a in + let len_b = js_obj_length b in + if len_a = len_b then + aux_same_length a b 0 len_a + else if len_a < len_b then + aux_length_a_short a b 0 len_a + else + aux_length_b_short a b 0 len_b +and aux_same_length (a : Obj.t) (b : Obj.t) i same_length = + if i = same_length then + 0 + else + let res = caml_compare (Obj.field a i) (Obj.field b i) in + if res !=0 then res + else aux_same_length a b (i + 1) same_length +and aux_length_a_short (a : Obj.t) (b : Obj.t) i short_length = + if i = short_length then -1 + else + let res = caml_compare (Obj.field a i) (Obj.field b i) in + if res !=0 then res + else aux_length_a_short a b (i+1) short_length +and aux_length_b_short (a : Obj.t) (b : Obj.t) i short_length = + if i = short_length then 1 + else + let res = caml_compare (Obj.field a i) (Obj.field b i) in + if res !=0 then res + else aux_length_b_short a b (i+1) short_length + +type eq = Obj.t -> Obj.t -> bool + +let rec caml_equal (a : Obj.t) (b : Obj.t) : bool = + if js_typeof a = "string" then a == b + else if js_typeof a = "number" then a == b + else + let tag_a = caml_obj_tag a in + let tag_b = caml_obj_tag b in + (* double_array_tag: 254 + forward_tag:250 + *) + if tag_a = 250 then + caml_equal (Obj.field a 0) b + else if tag_b = 250 then + caml_equal a (Obj.field b 0) + else if tag_a = 248 (* object/exception *) then + (Obj.magic @@ Obj.field a 1) == (Obj.magic @@ Obj.field b 1 ) + else if tag_a = 251 (* abstract_tag *) then + raise (Invalid_argument "equal: abstract value") + else if tag_a != tag_b then + false + else + let len_a = js_obj_length a in + let len_b = js_obj_length b in + if len_a = len_b then + aux_equal_length a b 0 len_a + else false +and aux_equal_length (a : Obj.t) (b : Obj.t) i same_length = + if i = same_length then + true + else + caml_equal (Obj.field a i) (Obj.field b i) + && aux_equal_length a b (i + 1) same_length + +let caml_notequal a b = not (caml_equal a b) + +let caml_int32_compare = caml_int_compare +let caml_nativeint_compare = caml_int_compare +let caml_greaterequal a b = caml_compare a b >= 0 + +let caml_greaterthan a b = caml_compare a b > 0 + +let caml_lessequal a b = caml_compare a b <= 0 + +let caml_lessthan a b = caml_compare a b < 0 + + + + diff --git a/jscomp/runtime/caml_obj.mli b/jscomp/runtime/caml_obj.mli new file mode 100644 index 0000000000..3ec173a6b5 --- /dev/null +++ b/jscomp/runtime/caml_obj.mli @@ -0,0 +1,58 @@ +(* OCamlScript compiler + * Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, with linking exception; + * either version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *) + +(* Author: Hongbo Zhang *) + +val caml_obj_dup : Obj.t -> Obj.t + +val caml_obj_truncate : Obj.t -> int -> unit + +(** + + TODO: Semantics difference + {[ + Obj.is_block (Obj.repr "x");; + true + ]} + + {[ + Obj.is_block (Obj.repr 32.0);; + true + ]} +*) +val caml_obj_is_block : Obj.t -> bool + +val caml_lazy_make_forward : 'a -> 'a lazy_t + +val caml_update_dummy : Obj.t -> Obj.t -> unit + +val caml_int_compare : int -> int -> int +val caml_int32_compare : int -> int -> int +val caml_nativeint_compare : int -> int -> int + +val caml_compare : Obj.t -> Obj.t -> int + +type eq = Obj.t -> Obj.t -> bool + +val caml_equal : eq +val caml_notequal : eq +val caml_greaterequal : eq +val caml_greaterthan : eq +val caml_lessthan : eq +val caml_lessequal : eq + diff --git a/jscomp/runtime/caml_obj_runtime.js b/jscomp/runtime/caml_obj_runtime.js deleted file mode 100644 index 1491ea0eb8..0000000000 --- a/jscomp/runtime/caml_obj_runtime.js +++ /dev/null @@ -1,89 +0,0 @@ -// Js_of_ocaml runtime support -// http://www.ocsigen.org/js_of_ocaml/ -// Copyright (C) 2014 Jérôme Vouillon, Hugo Heuzard, Andy Ray -// Laboratoire PPS - CNRS Université Paris Diderot -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, with linking exception; -// either version 2.1 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Copyright (c) 2015 Bloomberg LP. All rights reserved. -// Hongbo Zhang (hzhang295@bloomberg.net) -'use strict'; -var caml_exceptions_1 = require('./caml_exceptions'); -/** - * external is_block : t -> bool = "caml_obj_is_block" - * obj.ml - * TODO: figure out the semantics - * @param x - * @returns {number} - */ -function caml_obj_is_block(x) { return +(x instanceof Array); } -exports.caml_obj_is_block = caml_obj_is_block; -/** - * TODO: Semantics - * @param x - * @returns {number} - */ -function caml_obj_tag(x) { return (x instanceof Array) ? x[0] : (x instanceof String) ? 252 : 1000; } -exports.caml_obj_tag = caml_obj_tag; -/** - * TODO: semantics - * @param x - * @param tag - * @returns {number} - */ -function caml_obj_set_tag(x, tag) { x[0] = tag; return 0; } -exports.caml_obj_set_tag = caml_obj_set_tag; -/** - * TODO: we should inline when tag, size is known at compile time and size is not very big - * TODO: Semantics - * Question: Do we need intialize the block? seems not necessary - * @param tag - * @param size - * @returns {any[]} - */ -function caml_obj_block(tag, size) { - var o = new Array(size + 1); - o[0] = tag; - // TODO: intialization seems unnecessary - for (var i = 1; i <= size; i++) - o[i] = 0; - return o; -} -exports.caml_obj_block = caml_obj_block; -/** - * TODO: semantics - * @param x - * @returns {any[]} - */ -function caml_obj_dup(x) { - // According to http://jsperf.com/new-array-vs-splice-vs-slice/31 - return x.slice(); -} -exports.caml_obj_dup = caml_obj_dup; -/** - * TODO: semantics - * @param x - * @param s - * @returns {number} - */ -function caml_obj_truncate(x, s) { - if (s <= 0 || s + 1 > x.length) - caml_exceptions_1.caml_invalid_argument("Obj.truncate"); - if (x.length != s + 1) - x.length = s + 1; - return 0; -} -exports.caml_obj_truncate = caml_obj_truncate; -function caml_lazy_make_forward(v) { return [250, v]; } -exports.caml_lazy_make_forward = caml_lazy_make_forward; diff --git a/jscomp/runtime/caml_obj_runtime.ts b/jscomp/runtime/caml_obj_runtime.ts deleted file mode 100644 index 170e89670a..0000000000 --- a/jscomp/runtime/caml_obj_runtime.ts +++ /dev/null @@ -1,99 +0,0 @@ -// Js_of_ocaml runtime support -// http://www.ocsigen.org/js_of_ocaml/ -// Copyright (C) 2014 Jérôme Vouillon, Hugo Heuzard, Andy Ray -// Laboratoire PPS - CNRS Université Paris Diderot -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, with linking exception; -// either version 2.1 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -// Copyright (c) 2015 Bloomberg LP. All rights reserved. -// Hongbo Zhang (hzhang295@bloomberg.net) - -'use strict'; -import {caml_invalid_argument} from './caml_exceptions' -/** - * external is_block : t -> bool = "caml_obj_is_block" - * obj.ml - * TODO: figure out the semantics - * @param x - * @returns {number} - */ -function caml_obj_is_block (x) { return +(x instanceof Array); } - -/** - * TODO: Semantics - * @param x - * @returns {number} - */ -function caml_obj_tag (x) { return (x instanceof Array)?x[0]:(x instanceof String)?252:1000; } - -/** - * TODO: semantics - * @param x - * @param tag - * @returns {number} - */ -function caml_obj_set_tag (x, tag) { x[0] = tag; return 0; } - -/** - * TODO: we should inline when tag, size is known at compile time and size is not very big - * TODO: Semantics - * Question: Do we need intialize the block? seems not necessary - * @param tag - * @param size - * @returns {any[]} - */ -function caml_obj_block (tag, size) { - var o = new Array(size+1); - o[0]=tag; - // TODO: intialization seems unnecessary - for (var i = 1; i <= size; i++) o[i] = 0; - return o; -} - -/** - * TODO: semantics - * @param x - * @returns {any[]} - */ -function caml_obj_dup (x) { - // According to http://jsperf.com/new-array-vs-splice-vs-slice/31 - return x.slice(); -} - -/** - * TODO: semantics - * @param x - * @param s - * @returns {number} - */ -function caml_obj_truncate (x, s) { - if (s<=0 || s + 1 > x.length) - caml_invalid_argument ("Obj.truncate"); - if (x.length != s + 1) x.length = s + 1; - return 0; -} - -function caml_lazy_make_forward (v) { return [250, v]; } - - -export { - caml_obj_is_block, - caml_obj_tag, - caml_obj_set_tag, - caml_obj_block, - caml_obj_dup, - caml_obj_truncate, - caml_lazy_make_forward, -} \ No newline at end of file diff --git a/jscomp/runtime/caml_oo.js b/jscomp/runtime/caml_oo.js index 58a816e98d..6a624674d1 100644 --- a/jscomp/runtime/caml_oo.js +++ b/jscomp/runtime/caml_oo.js @@ -7,7 +7,7 @@ var Caml_array = require("./caml_array"); var caml_methods_cache = Caml_array.caml_make_vect(1000, 0); function caml_get_public_method(obj, tag, cacheid) { - var meths = obj[1]; + var meths = obj[0]; var offs = caml_methods_cache[cacheid]; if (meths[offs] === tag) { return meths[offs - 1]; @@ -18,10 +18,8 @@ function caml_get_public_method(obj, tag, cacheid) { var i = _i; if (i < 3) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "caml_oo.ml", 43, 20 diff --git a/jscomp/runtime/caml_parser.js b/jscomp/runtime/caml_parser.js new file mode 100644 index 0000000000..b8cce871d6 --- /dev/null +++ b/jscomp/runtime/caml_parser.js @@ -0,0 +1,355 @@ +// Js_of_ocaml runtime support +// http://www.ocsigen.org/js_of_ocaml/ +// Copyright (C) 2014 Jérôme Vouillon, Hugo Heuzard, Andy Ray +// Laboratoire PPS - CNRS Université Paris Diderot +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, with linking exception; +// either version 2.1 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// Copyright (c) 2015 Bloomberg LP. All rights reserved. +// Hongbo Zhang (hzhang295@bloomberg.net) +"use strict"; +/** + * caml_lex_array("abcd") + * [25185, 25699] + * @param s + * @returns {any[]} + * TODO: duplicated with module {!Caml_lex} + */ +function caml_lex_array(s) { + var l = s.length / 2; + var a = new Array(l); + for (var i = 0; i < l; i++) + a[i] = (s.charCodeAt(2 * i) | (s.charCodeAt(2 * i + 1) << 8)) << 16 >> 16; + return a; +} +/** + * Note that TS enum is not friendly to Closure compiler + * @enum{number} + */ +var Automata = { + START: 0, + LOOP: 6, + TOKEN_READ: 1, + TEST_SHIFT: 7, + ERROR_DETECTED: 5, + SHIFT: 8, + SHIFT_RECOVER: 9, + STACK_GROWN_1: 2, + REDUCE: 10, + STACK_GROWN_2: 3, + SEMANTIC_ACTION_COMPUTED: 4 +}; +/** + * @enum{number} + */ +var Result = { + READ_TOKEN: 0, + RAISE_PARSE_ERROR: 1, + GROW_STACKS_1: 2, + GROW_STACKS_2: 3, + COMPUTE_SEMANTIC_ACTION: 4, + CALL_ERROR_FUNCTION: 5 +}; +var PARSER_TRACE = false; +/** + * external parse_engine : parse_tables -> parser_env -> parser_input -> Obj.t -> parser_output + * parsing.ml + * + * type parse_tables = { + * actions : (parser_env -> Obj.t) array + * transl_const : int array; + * transl_block : int array; + * lhs : string; + * len : string; + * defred : string; + * dgoto : string; + * sindex : string; + * rindex : string; + * gindex : string; + * tablesize : int; + * table : string; + * check : string; + * error_function : string -> unit; + * names_const : string; + * names_block : string + * } + * + * type parser_env = + * { mutable s_stack : int array; (* States *) + * mutable v_stack : Obj.t array; (* Semantic attributes *) + * mutable symb_start_stack : position array; (* Start positions *) + * mutable symb_end_stack : position array; (* End positions *) + * mutable stacksize : int; (* Size of the stacks *) + * mutable stackbase : int; (* Base sp for current parse *) + * mutable curr_char : int; (* Last token read *) + * mutable lval : Obj.t; (* Its semantic attribute *) + * mutable symb_start : position; (* Start pos. of the current symbol*) + * mutable symb_end : position; (* End pos. of the current symbol *) + * mutable asp : int; (* The stack pointer for attributes *) + * mutable rule_len : int; (* Number of rhs items in the rule *) + * mutable rule_number : int; (* Rule number to reduce by *) + * mutable sp : int; (* Saved sp for parse_engine *) + * mutable state : int; (* Saved state for parse_engine *) + * mutable errflag : int } (* Saved error flag for parse_engine *) + * + * type parser_input = + * | Start + * | Token_read + * | Stacks_grown_1 + * | Stacks_grown_2 + * | Semantic_action_computed + * | Error_detected + + * @param tables + * @param env + * @param cmd + * @param arg + * @returns {number} + */ +function caml_parse_engine(tables /* parser_table */, env /* parser_env */, cmd /* parser_input*/, arg /* Obj.t*/) { + var ERRCODE = 256; + //var START = 0; + //var TOKEN_READ = 1; + //var STACKS_GROWN_1 = 2; + //var STACKS_GROWN_2 = 3; + //var SEMANTIC_ACTION_COMPUTED = 4; + //var ERROR_DETECTED = 5; + //var loop = 6; + //var testshift = 7; + //var shift = 8; + //var shift_recover = 9; + //var reduce = 10; + // Parsing.parser_env + var env_s_stack = 0; // array + var env_v_stack = 1; // array + var env_symb_start_stack = 2; // array + var env_symb_end_stack = 3; // array + var env_stacksize = 4; + var env_stackbase = 5; + var env_curr_char = 6; + var env_lval = 7; // Obj.t + var env_symb_start = 8; // position + var env_symb_end = 9; // position + var env_asp = 10; + var env_rule_len = 11; + var env_rule_number = 12; + var env_sp = 13; + var env_state = 14; + var env_errflag = 15; + // Parsing.parse_tables + // var _tbl_actions = 1; + var tbl_transl_const = 1; // array + var tbl_transl_block = 2; // array + var tbl_lhs = 3; + var tbl_len = 4; + var tbl_defred = 5; + var tbl_dgoto = 6; + var tbl_sindex = 7; + var tbl_rindex = 8; + var tbl_gindex = 9; + var tbl_tablesize = 10; + var tbl_table = 11; + var tbl_check = 12; + // var _tbl_error_function = 14; + // var _tbl_names_const = 15; + // var _tbl_names_block = 16; + if (!tables.dgoto) { + tables.defred = caml_lex_array(tables[tbl_defred]); + tables.sindex = caml_lex_array(tables[tbl_sindex]); + tables.check = caml_lex_array(tables[tbl_check]); + tables.rindex = caml_lex_array(tables[tbl_rindex]); + tables.table = caml_lex_array(tables[tbl_table]); + tables.len = caml_lex_array(tables[tbl_len]); + tables.lhs = caml_lex_array(tables[tbl_lhs]); + tables.gindex = caml_lex_array(tables[tbl_gindex]); + tables.dgoto = caml_lex_array(tables[tbl_dgoto]); + } + var res; + var n, n1, n2, state1; + // RESTORE + var sp = env[env_sp]; + var state = env[env_state]; + var errflag = env[env_errflag]; + exit: for (;;) { + //console.error("State", Automata[cmd]); + switch (cmd) { + case Automata.START: + state = 0; + errflag = 0; + // Fall through + case Automata.LOOP: + n = tables.defred[state]; + if (n != 0) { + cmd = Automata.REDUCE; + break; + } + if (env[env_curr_char] >= 0) { + cmd = Automata.TEST_SHIFT; + break; + } + res = Result.READ_TOKEN; + break exit; + /* The ML code calls the lexer and updates */ + /* symb_start and symb_end */ + case Automata.TOKEN_READ: + if (typeof arg !== 'number') { + env[env_curr_char] = tables[tbl_transl_block][arg.tag | 0 /* + 1 */]; + env[env_lval] = arg[0]; + } + else { + env[env_curr_char] = tables[tbl_transl_const][arg /* + 1 */]; + env[env_lval] = 0; + } + if (PARSER_TRACE) { + console.error("State %d, read token", state, arg); + } + // Fall through + case Automata.TEST_SHIFT: + n1 = tables.sindex[state]; + n2 = n1 + env[env_curr_char]; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == env[env_curr_char]) { + cmd = Automata.SHIFT; + break; + } + n1 = tables.rindex[state]; + n2 = n1 + env[env_curr_char]; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == env[env_curr_char]) { + n = tables.table[n2]; + cmd = Automata.REDUCE; + break; + } + if (errflag <= 0) { + res = Result.CALL_ERROR_FUNCTION; + break exit; + } + // Fall through + /* The ML code calls the error function */ + case Automata.ERROR_DETECTED: + if (errflag < 3) { + errflag = 3; + for (;;) { + state1 = env[env_s_stack][sp /* + 1*/]; + n1 = tables.sindex[state1]; + n2 = n1 + ERRCODE; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == ERRCODE) { + cmd = Automata.SHIFT_RECOVER; + break; + } + else { + if (sp <= env[env_stackbase]) + return Result.RAISE_PARSE_ERROR; + /* The ML code raises Parse_error */ + sp--; + } + } + } + else { + if (env[env_curr_char] == 0) + return Result.RAISE_PARSE_ERROR; + /* The ML code raises Parse_error */ + env[env_curr_char] = -1; + cmd = Automata.LOOP; + break; + } + // Fall through + case Automata.SHIFT: + env[env_curr_char] = -1; + if (errflag > 0) + errflag--; + // Fall through + case Automata.SHIFT_RECOVER: + if (PARSER_TRACE) { + console.error("State %d: shift to state %d", state, tables.table[n2]); + } + state = tables.table[n2]; + sp++; + if (sp >= env[env_stacksize]) { + res = Result.GROW_STACKS_1; + break exit; + } + // Fall through + /* The ML code resizes the stacks */ + case Automata.STACK_GROWN_1: + env[env_s_stack][sp /* + 1 */] = state; + env[env_v_stack][sp /* + 1 */] = env[env_lval]; + env[env_symb_start_stack][sp /* + 1 */] = env[env_symb_start]; + env[env_symb_end_stack][sp /* + 1 */] = env[env_symb_end]; + cmd = Automata.LOOP; + break; + case Automata.REDUCE: + if (PARSER_TRACE) { + console.error("State %d : reduce by rule %d", state, n); + } + var m = tables.len[n]; + env[env_asp] = sp; + env[env_rule_number] = n; + env[env_rule_len] = m; + sp = sp - m + 1; + m = tables.lhs[n]; + state1 = env[env_s_stack][sp - 1]; // + n1 = tables.gindex[m]; + n2 = n1 + state1; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == state1) + state = tables.table[n2]; + else + state = tables.dgoto[m]; + if (sp >= env[env_stacksize]) { + res = Result.GROW_STACKS_2; + break exit; + } + // Fall through + /* The ML code resizes the stacks */ + case Automata.STACK_GROWN_2: + res = Result.COMPUTE_SEMANTIC_ACTION; + break exit; + /* The ML code calls the semantic action */ + case Automata.SEMANTIC_ACTION_COMPUTED: + env[env_s_stack][sp /* + 1 */] = state; + env[env_v_stack][sp /* + 1*/] = arg; + var asp = env[env_asp]; + env[env_symb_end_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /* + 1*/]; + if (sp > asp) { + /* This is an epsilon production. Take symb_start equal to symb_end. */ + env[env_symb_start_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /*+ 1*/]; + } + cmd = Automata.LOOP; + break; + /* Should not happen */ + default: + return Result.RAISE_PARSE_ERROR; + } + } + // SAVE + env[env_sp] = sp; + env[env_state] = state; + env[env_errflag] = errflag; + return res; +} +exports.caml_parse_engine = caml_parse_engine; +/** + * external set_trace: bool -> bool = "caml_set_parser_trace" + * parsing.ml + * @param {boolean} + * @returns {boolean} + */ +function caml_set_parser_trace(v) { + var old = PARSER_TRACE; + PARSER_TRACE = v; + return old; +} +exports.caml_set_parser_trace = caml_set_parser_trace; diff --git a/jscomp/runtime/caml_parser.ts b/jscomp/runtime/caml_parser.ts new file mode 100644 index 0000000000..e260e02c2b --- /dev/null +++ b/jscomp/runtime/caml_parser.ts @@ -0,0 +1,369 @@ +// Js_of_ocaml runtime support +// http://www.ocsigen.org/js_of_ocaml/ +// Copyright (C) 2014 Jérôme Vouillon, Hugo Heuzard, Andy Ray +// Laboratoire PPS - CNRS Université Paris Diderot +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, with linking exception; +// either version 2.1 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Copyright (c) 2015 Bloomberg LP. All rights reserved. +// Hongbo Zhang (hzhang295@bloomberg.net) + +"use strict"; + +/** + * caml_lex_array("abcd") + * [25185, 25699] + * @param s + * @returns {any[]} + * TODO: duplicated with module {!Caml_lex} + */ +function caml_lex_array(s : string) { + var l = s.length / 2; + var a = new Array(l); + for (var i = 0; i < l; i++) + a[i] = (s.charCodeAt(2 * i) | (s.charCodeAt(2 * i + 1) << 8)) << 16 >> 16; + return a; +} + +/** + * Note that TS enum is not friendly to Closure compiler + * @enum{number} + */ +var Automata = { + START : 0, + LOOP : 6, + TOKEN_READ : 1, + TEST_SHIFT : 7, + ERROR_DETECTED : 5, + SHIFT : 8, + SHIFT_RECOVER : 9, + STACK_GROWN_1 : 2, + REDUCE : 10, + STACK_GROWN_2 : 3, + SEMANTIC_ACTION_COMPUTED : 4 +} +/** + * @enum{number} + */ +var Result = { + READ_TOKEN : 0, + RAISE_PARSE_ERROR : 1, + GROW_STACKS_1 : 2, + GROW_STACKS_2 : 3, + COMPUTE_SEMANTIC_ACTION : 4, + CALL_ERROR_FUNCTION : 5 +} + +var PARSER_TRACE = false; + +/** + * external parse_engine : parse_tables -> parser_env -> parser_input -> Obj.t -> parser_output + * parsing.ml + * + * type parse_tables = { + * actions : (parser_env -> Obj.t) array + * transl_const : int array; + * transl_block : int array; + * lhs : string; + * len : string; + * defred : string; + * dgoto : string; + * sindex : string; + * rindex : string; + * gindex : string; + * tablesize : int; + * table : string; + * check : string; + * error_function : string -> unit; + * names_const : string; + * names_block : string + * } + * + * type parser_env = + * { mutable s_stack : int array; (* States *) + * mutable v_stack : Obj.t array; (* Semantic attributes *) + * mutable symb_start_stack : position array; (* Start positions *) + * mutable symb_end_stack : position array; (* End positions *) + * mutable stacksize : int; (* Size of the stacks *) + * mutable stackbase : int; (* Base sp for current parse *) + * mutable curr_char : int; (* Last token read *) + * mutable lval : Obj.t; (* Its semantic attribute *) + * mutable symb_start : position; (* Start pos. of the current symbol*) + * mutable symb_end : position; (* End pos. of the current symbol *) + * mutable asp : int; (* The stack pointer for attributes *) + * mutable rule_len : int; (* Number of rhs items in the rule *) + * mutable rule_number : int; (* Rule number to reduce by *) + * mutable sp : int; (* Saved sp for parse_engine *) + * mutable state : int; (* Saved state for parse_engine *) + * mutable errflag : int } (* Saved error flag for parse_engine *) + * + * type parser_input = + * | Start + * | Token_read + * | Stacks_grown_1 + * | Stacks_grown_2 + * | Semantic_action_computed + * | Error_detected + + * @param tables + * @param env + * @param cmd + * @param arg + * @returns {number} + */ +function caml_parse_engine(tables /* parser_table */, + env /* parser_env */, + cmd /* parser_input*/, + arg /* Obj.t*/) +{ + var ERRCODE = 256; + + //var START = 0; + //var TOKEN_READ = 1; + //var STACKS_GROWN_1 = 2; + //var STACKS_GROWN_2 = 3; + //var SEMANTIC_ACTION_COMPUTED = 4; + //var ERROR_DETECTED = 5; + //var loop = 6; + //var testshift = 7; + //var shift = 8; + //var shift_recover = 9; + //var reduce = 10; + + + // Parsing.parser_env + var env_s_stack = 0; // array + var env_v_stack = 1; // array + var env_symb_start_stack = 2; // array + var env_symb_end_stack = 3; // array + var env_stacksize = 4; + var env_stackbase = 5; + var env_curr_char = 6; + var env_lval = 7; // Obj.t + var env_symb_start = 8; // position + var env_symb_end = 9; // position + var env_asp = 10; + var env_rule_len = 11; + var env_rule_number = 12; + var env_sp = 13; + var env_state = 14; + var env_errflag = 15; + + // Parsing.parse_tables + // var _tbl_actions = 1; + var tbl_transl_const = 1; // array + var tbl_transl_block = 2; // array + var tbl_lhs = 3; + var tbl_len = 4; + var tbl_defred = 5; + var tbl_dgoto = 6; + var tbl_sindex = 7; + var tbl_rindex = 8; + var tbl_gindex = 9; + var tbl_tablesize = 10; + var tbl_table = 11; + var tbl_check = 12; + // var _tbl_error_function = 14; + // var _tbl_names_const = 15; + // var _tbl_names_block = 16; + + if (!tables.dgoto) { + tables.defred = caml_lex_array (tables[tbl_defred]); + tables.sindex = caml_lex_array (tables[tbl_sindex]); + tables.check = caml_lex_array (tables[tbl_check]); + tables.rindex = caml_lex_array (tables[tbl_rindex]); + tables.table = caml_lex_array (tables[tbl_table]); + tables.len = caml_lex_array (tables[tbl_len]); + tables.lhs = caml_lex_array (tables[tbl_lhs]); + tables.gindex = caml_lex_array (tables[tbl_gindex]); + tables.dgoto = caml_lex_array (tables[tbl_dgoto]); + } + + var res; + var n, n1, n2, state1; + + // RESTORE + var sp = env[env_sp]; + var state = env[env_state]; + var errflag = env[env_errflag]; + + exit:for (;;) { + //console.error("State", Automata[cmd]); + + switch(cmd) { + case Automata.START://START: + state = 0; + errflag = 0; + // Fall through + + case Automata.LOOP://loop: + n = tables.defred[state]; + if (n != 0) { cmd = Automata.REDUCE; break; } + if (env[env_curr_char] >= 0) { cmd = Automata.TEST_SHIFT; break; } + res = Result.READ_TOKEN; + break exit; + /* The ML code calls the lexer and updates */ + /* symb_start and symb_end */ + case Automata.TOKEN_READ://TOKEN_READ: + if (typeof arg !== 'number') { + env[env_curr_char] = tables[tbl_transl_block][arg.tag | 0 /* + 1 */]; + env[env_lval] = arg[0]; + } else { + env[env_curr_char] = tables[tbl_transl_const][arg /* + 1 */]; + env[env_lval] = 0; + } + if(PARSER_TRACE){ + console.error("State %d, read token", state, arg) + } + // Fall through + + case Automata.TEST_SHIFT://testshift: + n1 = tables.sindex[state]; + n2 = n1 + env[env_curr_char]; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == env[env_curr_char]) { + cmd = Automata.SHIFT; break; + } + n1 = tables.rindex[state]; + n2 = n1 + env[env_curr_char]; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == env[env_curr_char]) { + n = tables.table[n2]; + cmd = Automata.REDUCE; break; + } + if (errflag <= 0) { + + res = Result.CALL_ERROR_FUNCTION; + break exit; + } + // Fall through + /* The ML code calls the error function */ + case Automata.ERROR_DETECTED://ERROR_DETECTED: + if (errflag < 3) { + errflag = 3; + for (;;) { + state1 = env[env_s_stack][sp /* + 1*/]; + n1 = tables.sindex[state1]; + n2 = n1 + ERRCODE; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == ERRCODE) { + cmd = Automata.SHIFT_RECOVER; break; + } else { + if (sp <= env[env_stackbase]) return Result.RAISE_PARSE_ERROR; + /* The ML code raises Parse_error */ + sp--; + } + } + } else { + if (env[env_curr_char] == 0) return Result.RAISE_PARSE_ERROR; + /* The ML code raises Parse_error */ + env[env_curr_char] = -1; + cmd = Automata.LOOP; break; + } + // Fall through + case Automata.SHIFT://shift: + env[env_curr_char] = -1; + if (errflag > 0) errflag--; + // Fall through + case Automata.SHIFT_RECOVER://shift_recover: + if(PARSER_TRACE) { + console.error("State %d: shift to state %d", state, tables.table[n2]) + } + state = tables.table[n2]; + sp++; + if (sp >= env[env_stacksize]) { + res = Result.GROW_STACKS_1; + break exit; + } + // Fall through + /* The ML code resizes the stacks */ + case Automata.STACK_GROWN_1: + env[env_s_stack][sp /* + 1 */] = state; + env[env_v_stack][sp /* + 1 */] = env[env_lval]; + env[env_symb_start_stack][sp /* + 1 */] = env[env_symb_start]; + env[env_symb_end_stack][sp /* + 1 */] = env[env_symb_end]; + cmd = Automata.LOOP; + break; + + case Automata.REDUCE: + if(PARSER_TRACE) { + console.error("State %d : reduce by rule %d", state, n) + } + var m = tables.len[n]; + env[env_asp] = sp; + env[env_rule_number] = n; + env[env_rule_len] = m; + sp = sp - m + 1; + m = tables.lhs[n]; + state1 = env[env_s_stack][sp - 1]; // + + n1 = tables.gindex[m]; + n2 = n1 + state1; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == state1) + state = tables.table[n2]; + else + state = tables.dgoto[m]; + if (sp >= env[env_stacksize]) { + res = Result.GROW_STACKS_2; + break exit; + } + // Fall through + /* The ML code resizes the stacks */ + case Automata.STACK_GROWN_2://STACKS_GROWN_2: + res = Result.COMPUTE_SEMANTIC_ACTION; + break exit; + /* The ML code calls the semantic action */ + case Automata.SEMANTIC_ACTION_COMPUTED://SEMANTIC_ACTION_COMPUTED: + env[env_s_stack][sp /* + 1 */] = state; + env[env_v_stack][sp /* + 1*/] = arg; + var asp = env[env_asp]; + env[env_symb_end_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /* + 1*/]; + if (sp > asp) { + /* This is an epsilon production. Take symb_start equal to symb_end. */ + env[env_symb_start_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /*+ 1*/]; + } + cmd = Automata.LOOP; break; + /* Should not happen */ + default: + return Result.RAISE_PARSE_ERROR; + } + } + // SAVE + env[env_sp] = sp; + env[env_state] = state; + env[env_errflag] = errflag; + + return res; +} + + + +/** + * external set_trace: bool -> bool = "caml_set_parser_trace" + * parsing.ml + * @param {boolean} + * @returns {boolean} + */ +function caml_set_parser_trace(v : boolean) { + var old = PARSER_TRACE; + PARSER_TRACE = v; + return old; +} + +export { + caml_parse_engine, + caml_set_parser_trace +} \ No newline at end of file diff --git a/jscomp/runtime/caml_primitive.js b/jscomp/runtime/caml_primitive.js index c2cadb2cdd..346f8fcdee 100644 --- a/jscomp/runtime/caml_primitive.js +++ b/jscomp/runtime/caml_primitive.js @@ -20,167 +20,6 @@ // Hongbo Zhang (hzhang295@bloomberg.net) "use strict"; var caml_exceptions_1 = require('./caml_exceptions'); -function caml_update_dummy(x, y) { - var i = y.length; - while (i--) { - x[i] = y[i]; - } - ; - return 0; -} -exports.caml_update_dummy = caml_update_dummy; -function caml_compare_val(a, b, total) { - var stack = []; - for (;;) { - if (!(total && a === b)) { - if (a === b) { - return 0; - } - if (typeof a === 'string') { - if (a < b) { - return -1; - } - else { - return 1; - } - } - else if (a instanceof Array && a[0] === (a[0] | 0)) { - var ta = a[0]; - // ignore double_array_tag - if (ta === 254) - ta = 0; - // Forward object - if (ta === 250) { - a = a[1]; - continue; - } - else if (b instanceof Array && b[0] === (b[0] | 0)) { - var tb = b[0]; - // ignore double_array_tag - if (tb === 254) - tb = 0; - // Forward object - if (tb === 250) { - b = b[1]; - continue; - } - else if (ta != tb) { - return (ta < tb) ? -1 : 1; - } - else { - switch (ta) { - case 248: { - // Object - var x = caml_int_compare(a[2], b[2]); - if (x != 0) - return x; - break; - } - case 251: { - caml_exceptions_1.caml_invalid_argument("equal: abstract value"); - } - /* - * TODO: generic comparison - case 255: { - // Int64 - var x = caml_int64_compare(a, b); - if (x != 0) return x; - break; - } - */ - default: - if (a.length != b.length) - return (a.length < b.length) ? -1 : 1; - if (a.length > 1) - stack.push(a, b, 1); - } - } - } - else - return 1; - } - else if (b instanceof String || - (b instanceof Array && b[0] === (b[0] | 0))) { - return -1; - } - else if (typeof a != "number" && a && a.compare) { - return a.compare(b, total); - } - else { - if (a < b) - return -1; - if (a > b) - return 1; - if (a != b) { - if (!total) - return NaN; - if (a == a) - return 1; - if (b == b) - return -1; - } - } - } - if (stack.length == 0) - return 0; - var i = stack.pop(); - b = stack.pop(); - a = stack.pop(); - if (i + 1 < a.length) - stack.push(a, b, i + 1); - a = a[i]; - b = b[i]; - } -} -function caml_compare(a, b) { return caml_compare_val(a, b, 1); } -exports.caml_compare = caml_compare; -/** - * TODO: shall we Inline it? - * @param a - * @param b - * @returns {number} - */ -function caml_int_compare(a, b) { - if (a < b) - return (-1); - if (a === b) - return 0; - return 1; -} -exports.caml_int_compare = caml_int_compare; -exports.caml_int32_compare = caml_int_compare; -exports.caml_nativeint_compare = caml_int_compare; -/** - * @returns {number} - * Currently ocaml only has number not boolean, and we can not - * use boolean instead of number directly, since a boolean maybe - * used in pattern match and generate code such as `x!==0` - * Note we use `+boolean` to convert - * +true -> 1 - * +false -> 0 - */ -function caml_equal(x, y) { return +(caml_compare_val(x, y, false) == 0); } -exports.caml_equal = caml_equal; -function caml_notequal(x, y) { - return +(caml_compare_val(x, y, false) != 0); -} -exports.caml_notequal = caml_notequal; -function caml_greaterequal(x, y) { - return +(caml_compare_val(x, y, false) >= 0); -} -exports.caml_greaterequal = caml_greaterequal; -function caml_greaterthan(x, y) { - return +(caml_compare_val(x, y, false) > 0); -} -exports.caml_greaterthan = caml_greaterthan; -function caml_lessequal(x, y) { - return +(caml_compare_val(x, y, false) <= 0); -} -exports.caml_lessequal = caml_lessequal; -function caml_lessthan(x, y) { - return +(caml_compare_val(x, y, false) < 0); -} -exports.caml_lessthan = caml_lessthan; function caml_convert_raw_backtrace_slot() { caml_exceptions_1.caml_failwith("caml_convert_raw_backtrace_slot"); } @@ -211,59 +50,6 @@ function caml_int64_bswap(x) { ((x[1] & 0x000000ff) << 8))]; } exports.caml_int64_bswap = caml_int64_bswap; -function caml_CamlinternalMod_init_mod(loc, shape) { - function undef_module(_x) { - caml_exceptions_1.caml_undef_module(loc); - } - function loop(shape, struct, idx) { - if (typeof shape === "number") - switch (shape) { - case 0: - struct[idx] = { fun: undef_module }; - break; - case 1: - struct[idx] = [246, undef_module]; - break; - default: - struct[idx] = []; - } - else - switch (shape[0]) { - case 0: - struct[idx] = [0]; - for (var i = 1; i < shape[1].length; i++) - loop(shape[1][i], struct[idx], i); - break; - default: - struct[idx] = shape[1]; - } - } - var res = []; - loop(shape, res, 0); - return res[0]; -} -function caml_CamlinternalMod_update_mod(shape, real, x) { - if (typeof shape === "number") - switch (shape) { - case 0: - real.fun = x; - break; - case 1: //lazy - default: - caml_update_dummy(real, x); - } - else - switch (shape[0]) { - case 0: - for (var i = 1; i < shape[1].length; i++) - caml_CamlinternalMod_update_mod(shape[1][i], real[i], x[i]); - break; - //case 1://Value - default: - } - ; - return 0; -} /** * Maximum value of #goog.string.hashCode, exclusive. 2^32. * @type {number} diff --git a/jscomp/runtime/caml_primitive.ts b/jscomp/runtime/caml_primitive.ts index fb00bde3fa..7fea96a1ef 100644 --- a/jscomp/runtime/caml_primitive.ts +++ b/jscomp/runtime/caml_primitive.ts @@ -25,145 +25,12 @@ import {caml_failwith, caml_invalid_argument, caml_undef_module} from './caml_exceptions' import {Undefined_recursive_module } from './caml_builtin_exceptions' import {caml_array_sub} from './caml_array' +import {caml_update_dummy} from './caml_obj' -function caml_update_dummy (x, y) { - var i = y.length; - while (i--) { - x[i] = y[i] - }; - return 0; -} - - - - - -function caml_compare_val (a, b, total) { - var stack = []; - for(;;) { - if (!(total && a === b)) { - if (a === b) {return 0} - if (typeof a === 'string') { - if(a 1) stack.push(a, b, 1); - } - } - } else - return 1; - } else if (b instanceof String || - (b instanceof Array && b[0] === (b[0]|0))) { - return -1; - } else if (typeof a != "number" && a && a.compare) { - return a.compare(b,total); - } else { - if (a < b) return -1; - if (a > b) return 1; - if (a != b) { - if (!total) return NaN; - if (a == a) return 1; - if (b == b) return -1; - } - } - } - if (stack.length == 0) return 0; - var i = stack.pop(); - b = stack.pop(); - a = stack.pop(); - if (i + 1 < a.length) stack.push(a, b, i + 1); - a = a[i]; - b = b[i]; - } -} -function caml_compare (a, b) { return caml_compare_val (a, b, 1); } - -/** - * TODO: shall we Inline it? - * @param a - * @param b - * @returns {number} - */ -function caml_int_compare (a : number, b : number) { - if (a < b) return (-1); if (a === b) return 0; return 1; -} - -// #define cmp(x,y) (x-y) -// That won't work if x and y are both of unsigned integral type. - -type Boolean = number - -/** - * @returns {number} - * Currently ocaml only has number not boolean, and we can not - * use boolean instead of number directly, since a boolean maybe - * used in pattern match and generate code such as `x!==0` - * Note we use `+boolean` to convert - * +true -> 1 - * +false -> 0 - */ -function caml_equal (x, y) : Boolean { return +(caml_compare_val(x,y,false) == 0); } - -function caml_notequal (x, y) : Boolean { - return +(caml_compare_val(x,y,false) != 0); -} - -function caml_greaterequal (x, y) : Boolean { - return +(caml_compare_val(x,y,false) >= 0); -} -function caml_greaterthan (x, y) : Boolean { - return +(caml_compare_val(x,y,false) > 0); -} -function caml_lessequal (x, y) : Boolean { - return +(caml_compare_val(x,y,false) <= 0); -} -function caml_lessthan (x, y) : Boolean { - return +(caml_compare_val(x,y,false) < 0); -} - function caml_convert_raw_backtrace_slot(){ caml_failwith("caml_convert_raw_backtrace_slot"); } @@ -199,60 +66,6 @@ function caml_int64_bswap(x) { -function caml_CamlinternalMod_init_mod(loc,shape) { - function undef_module (_x) { - caml_undef_module(loc); - } - function loop (shape,struct,idx){ - if(typeof shape === "number") - switch(shape){ - case 0://function - struct[idx]={fun:undef_module}; - break; - case 1://lazy - struct[idx]=[246, undef_module]; - break; - default://case 2://class - struct[idx]=[]; - } - else - switch(shape[0]){ - case 0://module - struct[idx] = [0]; - for(var i=1;i= s.length || i < 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "index out of bounds" ]; @@ -23,7 +22,6 @@ function caml_string_get(s, i) { function caml_create_string(len) { if (len < 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.create" ]; diff --git a/jscomp/runtime/caml_string.ml b/jscomp/runtime/caml_string.ml index 6c2464165b..d2f15b8e5d 100644 --- a/jscomp/runtime/caml_string.ml +++ b/jscomp/runtime/caml_string.ml @@ -133,7 +133,7 @@ let string_of_large_bytes bytes i len = end let bytes_to_string a = - string_of_large_bytes a 0 (String.length a) + string_of_large_bytes a 0 (Bytes.length a) (** TODO: performance could be improved, however, diff --git a/jscomp/runtime/runtime.mllib b/jscomp/runtime/runtime.mllib index be15bdb1b9..8e049620a8 100644 --- a/jscomp/runtime/runtime.mllib +++ b/jscomp/runtime/runtime.mllib @@ -2,4 +2,5 @@ caml_curry caml_array caml_string caml_oo -caml_exceptions \ No newline at end of file +caml_exceptions +caml_obj diff --git a/jscomp/stdlib/arg.js b/jscomp/stdlib/arg.js index 9ee5a5d36e..b387e1752b 100644 --- a/jscomp/stdlib/arg.js +++ b/jscomp/stdlib/arg.js @@ -2,44 +2,47 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("./pervasives"); var Caml_format = require("../runtime/caml_format"); var Sys = require("./sys"); var Printf = require("./printf"); -var Caml_primitive = require("../runtime/caml_primitive"); var Buffer = require("./buffer"); var Caml_curry = require("../runtime/caml_curry"); var $$String = require("./string"); var List = require("./list"); -var Bad = [ - 248, - "Arg.Bad", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Bad = { + 0: "Arg.Bad", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; -var Help = [ - 248, - "Arg.Help", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Help = { + 0: "Arg.Help", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; -var Stop = [ - 248, - "Arg.Stop", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Stop = { + 0: "Arg.Stop", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function assoc3(x, _l) { while(true) { var l = _l; if (l) { - var match = l[1]; - if (Caml_primitive.caml_equal(match[1], x)) { - return match[2]; + var match = l[0]; + if (Caml_obj.caml_equal(match[0], x)) { + return match[1]; } else { - _l = l[2]; + _l = l[1]; continue ; } @@ -54,7 +57,7 @@ function make_symlist(prefix, sep, suffix, l) { if (l) { return List.fold_left(function (x, y) { return x + (sep + y); - }, prefix + l[1], l[2]) + suffix; + }, prefix + l[0], l[1]) + suffix; } else { return ""; @@ -63,12 +66,12 @@ function make_symlist(prefix, sep, suffix, l) { function help_action() { throw [ - 0, Stop, - [ - /* Unknown */0, - "-help" - ] + /* Unknown */{ + 0: "-help", + length: 1, + tag: 0 + } ]; } @@ -80,15 +83,14 @@ function add_help(speclist) { } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - add1 = [ - /* :: */0, - [ - /* tuple */0, + add1 = /* :: */[ + /* tuple */[ "-help", - [ - /* Unit */0, - help_action - ], + /* Unit */{ + 0: help_action, + length: 1, + tag: 0 + }, " Display this list of options" ], /* [] */0 @@ -105,15 +107,14 @@ function add_help(speclist) { } catch (exn$1){ if (exn$1 === Caml_builtin_exceptions.Not_found) { - add2 = [ - /* :: */0, - [ - /* tuple */0, + add2 = /* :: */[ + /* tuple */[ "--help", - [ - /* Unit */0, - help_action - ], + /* Unit */{ + 0: help_action, + length: 1, + tag: 0 + }, " Display this list of options" ], /* [] */0 @@ -127,83 +128,99 @@ function add_help(speclist) { } function usage_b(buf, speclist, errmsg) { - Caml_curry.app1(Printf.bprintf(buf, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ], - "%s\n" - ]), errmsg); + Caml_curry.app1(Printf.bprintf(buf, /* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + 1: "%s\n", + length: 2, + tag: 0 + }), errmsg); return List.iter(function (param) { var buf$1 = buf; var param$1 = param; - var doc = param$1[3]; - var spec = param$1[2]; - var key = param$1[1]; + var doc = param$1[2]; + var spec = param$1[1]; + var key = param$1[0]; if (doc.length) { - if (spec[0] === 11) { - return Caml_curry.app3(Printf.bprintf(buf$1, [ - /* Format */0, - [ - /* String_literal */11, - " ", - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* " " */32, - [ - /* String */2, - /* No_padding */0, - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ] - ] - ] - ], - " %s %s%s\n" - ]), key, make_symlist("{", "|", "}", spec[1]), doc); + if (spec.tag === 11) { + return Caml_curry.app3(Printf.bprintf(buf$1, /* Format */{ + 0: /* String_literal */{ + 0: " ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* " " */32, + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: " %s %s%s\n", + length: 2, + tag: 0 + }), key, make_symlist("{", "|", "}", spec[0]), doc); } else { - return Caml_curry.app2(Printf.bprintf(buf$1, [ - /* Format */0, - [ - /* String_literal */11, - " ", - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* " " */32, - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ] - ] - ], - " %s %s\n" - ]), key, doc); + return Caml_curry.app2(Printf.bprintf(buf$1, /* Format */{ + 0: /* String_literal */{ + 0: " ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* " " */32, + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: " %s %s\n", + length: 2, + tag: 0 + }), key, doc); } } else { @@ -219,183 +236,207 @@ function usage_string(speclist, errmsg) { } function usage(speclist, errmsg) { - return Caml_curry.app1(Printf.eprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ]), usage_string(speclist, errmsg)); + return Caml_curry.app1(Printf.eprintf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + 1: "%s", + length: 2, + tag: 0 + }), usage_string(speclist, errmsg)); } -var current = [ - 0, - 0 -]; +var current = [0]; function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { - var current$1 = $staropt$star ? $staropt$star[1] : current; + var current$1 = $staropt$star ? $staropt$star[0] : current; var l = argv.length; var b = Buffer.create(200); - var initpos = current$1[1]; + var initpos = current$1[0]; var stop = function (error) { var progname = initpos < l ? argv[initpos] : "(?)"; - switch (error[0]) { + switch (error.tag | 0) { case 0 : - var s = error[1]; + var s = error[0]; switch (s) { case "--help" : case "-help" : break; default: - Caml_curry.app2(Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - ": unknown option '", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - "'.\n", - /* End_of_format */0 - ] - ] - ] - ], - "%s: unknown option '%s'.\n" - ]), progname, s); + Caml_curry.app2(Printf.bprintf(b, /* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": unknown option '", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: "'.\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + 1: "%s: unknown option '%s'.\n", + length: 2, + tag: 0 + }), progname, s); } break; case 1 : - Caml_curry.app4(Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - ": wrong argument '", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - "'; option '", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - "' expects ", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - ".\n", - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ], - "%s: wrong argument '%s'; option '%s' expects %s.\n" - ]), progname, error[2], error[1], error[3]); + Caml_curry.app4(Printf.bprintf(b, /* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": wrong argument '", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: "'; option '", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: "' expects ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ".\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + 1: "%s: wrong argument '%s'; option '%s' expects %s.\n", + length: 2, + tag: 0 + }), progname, error[1], error[0], error[2]); break; case 2 : - Caml_curry.app2(Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - ": option '", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - "' needs an argument.\n", - /* End_of_format */0 - ] - ] - ] - ], - "%s: option '%s' needs an argument.\n" - ]), progname, error[1]); + Caml_curry.app2(Printf.bprintf(b, /* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": option '", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: "' needs an argument.\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + 1: "%s: option '%s' needs an argument.\n", + length: 2, + tag: 0 + }), progname, error[0]); break; case 3 : - Caml_curry.app2(Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - ": ", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - ".\n", - /* End_of_format */0 - ] - ] - ] - ], - "%s: %s.\n" - ]), progname, error[1]); + Caml_curry.app2(Printf.bprintf(b, /* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ".\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + 1: "%s: %s.\n", + length: 2, + tag: 0 + }), progname, error[0]); break; } - usage_b(b, speclist[1], errmsg); - if (Caml_primitive.caml_equal(error, [ - /* Unknown */0, - "-help" - ]) || Caml_primitive.caml_equal(error, [ - /* Unknown */0, - "--help" - ])) { + usage_b(b, speclist[0], errmsg); + if (Caml_obj.caml_equal(error, /* Unknown */{ + 0: "-help", + length: 1, + tag: 0 + }) || Caml_obj.caml_equal(error, /* Unknown */{ + 0: "--help", + length: 1, + tag: 0 + })) { throw [ - 0, Help, Buffer.contents(b) ]; } else { throw [ - 0, Bad, Buffer.contents(b) ]; } }; - ++ current$1[1]; - while(current$1[1] < l) { - var s = argv[current$1[1]]; + ++ current$1[0]; + while(current$1[0] < l) { + var s = argv[current$1[0]]; if (s.length >= 1 && s[0] === "-") { var action; try { - action = assoc3(s, speclist[1]); + action = assoc3(s, speclist[0]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - action = stop([ - /* Unknown */0, - s - ]); + action = stop(/* Unknown */{ + 0: s, + length: 1, + tag: 0 + }); } else { throw exn; @@ -404,27 +445,27 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { try { var treat_action = (function(s){ return function (param) { - switch (param[0]) { + switch (param.tag | 0) { case 0 : - return Caml_curry.app1(param[1], /* () */0); + return Caml_curry.app1(param[0], /* () */0); case 1 : - if (current$1[1] + 1 < l) { - var arg = argv[current$1[1] + 1]; + if (current$1[0] + 1 < l) { + var arg = argv[current$1[0] + 1]; try { - Caml_curry.app1(param[1], Pervasives.bool_of_string(arg)); + Caml_curry.app1(param[0], Pervasives.bool_of_string(arg)); } catch (exn){ - if (exn[1] === Caml_builtin_exceptions.Invalid_argument) { - if (exn[2] === "bool_of_string") { + if (exn[0] === Caml_builtin_exceptions.Invalid_argument) { + if (exn[1] === "bool_of_string") { throw [ - 0, Stop, - [ - /* Wrong */1, - s, - arg, - "a boolean" - ] + /* Wrong */{ + 0: s, + 1: arg, + 2: "a boolean", + length: 3, + tag: 1 + } ]; } else { @@ -435,75 +476,75 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { throw exn; } } - return ++ current$1[1]; + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 2 : - param[1][1] = /* true */1; + param[0][0] = /* true */1; return /* () */0; case 3 : - param[1][1] = /* false */0; + param[0][0] = /* false */0; return /* () */0; case 4 : - if (current$1[1] + 1 < l) { - Caml_curry.app1(param[1], argv[current$1[1] + 1]); - return ++ current$1[1]; + if (current$1[0] + 1 < l) { + Caml_curry.app1(param[0], argv[current$1[0] + 1]); + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 5 : - if (current$1[1] + 1 < l) { - param[1][1] = argv[current$1[1] + 1]; - return ++ current$1[1]; + if (current$1[0] + 1 < l) { + param[0][0] = argv[current$1[0] + 1]; + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 6 : - if (current$1[1] + 1 < l) { - var arg$1 = argv[current$1[1] + 1]; + if (current$1[0] + 1 < l) { + var arg$1 = argv[current$1[0] + 1]; try { - Caml_curry.app1(param[1], Caml_format.caml_int_of_string(arg$1)); + Caml_curry.app1(param[0], Caml_format.caml_int_of_string(arg$1)); } catch (exn$1){ - if (exn$1[1] === Caml_builtin_exceptions.Failure) { - if (exn$1[2] === "int_of_string") { + if (exn$1[0] === Caml_builtin_exceptions.Failure) { + if (exn$1[1] === "int_of_string") { throw [ - 0, Stop, - [ - /* Wrong */1, - s, - arg$1, - "an integer" - ] + /* Wrong */{ + 0: s, + 1: arg$1, + 2: "an integer", + length: 3, + tag: 1 + } ]; } else { @@ -514,37 +555,37 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { throw exn$1; } } - return ++ current$1[1]; + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 7 : - if (current$1[1] + 1 < l) { - var arg$2 = argv[current$1[1] + 1]; + if (current$1[0] + 1 < l) { + var arg$2 = argv[current$1[0] + 1]; try { - param[1][1] = Caml_format.caml_int_of_string(arg$2); + param[0][0] = Caml_format.caml_int_of_string(arg$2); } catch (exn$2){ - if (exn$2[1] === Caml_builtin_exceptions.Failure) { - if (exn$2[2] === "int_of_string") { + if (exn$2[0] === Caml_builtin_exceptions.Failure) { + if (exn$2[1] === "int_of_string") { throw [ - 0, Stop, - [ - /* Wrong */1, - s, - arg$2, - "an integer" - ] + /* Wrong */{ + 0: s, + 1: arg$2, + 2: "an integer", + length: 3, + tag: 1 + } ]; } else { @@ -555,37 +596,37 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { throw exn$2; } } - return ++ current$1[1]; + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 8 : - if (current$1[1] + 1 < l) { - var arg$3 = argv[current$1[1] + 1]; + if (current$1[0] + 1 < l) { + var arg$3 = argv[current$1[0] + 1]; try { - Caml_curry.app1(param[1], Caml_format.caml_float_of_string(arg$3)); + Caml_curry.app1(param[0], Caml_format.caml_float_of_string(arg$3)); } catch (exn$3){ - if (exn$3[1] === Caml_builtin_exceptions.Failure) { - if (exn$3[2] === "float_of_string") { + if (exn$3[0] === Caml_builtin_exceptions.Failure) { + if (exn$3[1] === "float_of_string") { throw [ - 0, Stop, - [ - /* Wrong */1, - s, - arg$3, - "a float" - ] + /* Wrong */{ + 0: s, + 1: arg$3, + 2: "a float", + length: 3, + tag: 1 + } ]; } else { @@ -596,37 +637,37 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { throw exn$3; } } - return ++ current$1[1]; + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 9 : - if (current$1[1] + 1 < l) { - var arg$4 = argv[current$1[1] + 1]; + if (current$1[0] + 1 < l) { + var arg$4 = argv[current$1[0] + 1]; try { - param[1][1] = Caml_format.caml_float_of_string(arg$4); + param[0][0] = Caml_format.caml_float_of_string(arg$4); } catch (exn$4){ - if (exn$4[1] === Caml_builtin_exceptions.Failure) { - if (exn$4[2] === "float_of_string") { + if (exn$4[0] === Caml_builtin_exceptions.Failure) { + if (exn$4[1] === "float_of_string") { throw [ - 0, Stop, - [ - /* Wrong */1, - s, - arg$4, - "a float" - ] + /* Wrong */{ + 0: s, + 1: arg$4, + 2: "a float", + length: 3, + tag: 1 + } ]; } else { @@ -637,58 +678,58 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { throw exn$4; } } - return ++ current$1[1]; + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 10 : - return List.iter(treat_action, param[1]); + return List.iter(treat_action, param[0]); case 11 : - var symb = param[1]; - if (current$1[1] + 1 < l) { - var arg$5 = argv[current$1[1] + 1]; + var symb = param[0]; + if (current$1[0] + 1 < l) { + var arg$5 = argv[current$1[0] + 1]; if (List.mem(arg$5, symb)) { - Caml_curry.app1(param[2], argv[current$1[1] + 1]); - return ++ current$1[1]; + Caml_curry.app1(param[1], argv[current$1[0] + 1]); + return ++ current$1[0]; } else { throw [ - 0, Stop, - [ - /* Wrong */1, - s, - arg$5, - "one of: " + make_symlist("", " ", "", symb) - ] + /* Wrong */{ + 0: s, + 1: arg$5, + 2: "one of: " + make_symlist("", " ", "", symb), + length: 3, + tag: 1 + } ]; } } else { throw [ - 0, Stop, - [ - /* Missing */2, - s - ] + /* Missing */{ + 0: s, + length: 1, + tag: 2 + } ]; } break; case 12 : - var f = param[1]; - while(current$1[1] < l - 1) { - Caml_curry.app1(f, argv[current$1[1] + 1]); - ++ current$1[1]; + var f = param[0]; + while(current$1[0] < l - 1) { + Caml_curry.app1(f, argv[current$1[0] + 1]); + ++ current$1[0]; }; return /* () */0; @@ -698,51 +739,47 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { treat_action(action); } catch (exn$1){ - if (exn$1[1] === Bad) { - stop([ - /* Message */3, - exn$1[2] - ]); + if (exn$1[0] === Bad) { + stop(/* Message */{ + 0: exn$1[1], + length: 1, + tag: 3 + }); } - else if (exn$1[1] === Stop) { - stop(exn$1[2]); + else if (exn$1[0] === Stop) { + stop(exn$1[1]); } else { throw exn$1; } } - ++ current$1[1]; + ++ current$1[0]; } else { try { Caml_curry.app1(anonfun, s); } catch (exn$2){ - if (exn$2[1] === Bad) { - stop([ - /* Message */3, - exn$2[2] - ]); + if (exn$2[0] === Bad) { + stop(/* Message */{ + 0: exn$2[1], + length: 1, + tag: 3 + }); } else { throw exn$2; } } - ++ current$1[1]; + ++ current$1[0]; } }; return /* () */0; } function parse_argv($staropt$star, argv, speclist, anonfun, errmsg) { - var current$1 = $staropt$star ? $staropt$star[1] : current; - return parse_argv_dynamic([ - /* Some */0, - current$1 - ], argv, [ - 0, - speclist - ], anonfun, errmsg); + var current$1 = $staropt$star ? $staropt$star[0] : current; + return parse_argv_dynamic(/* Some */[current$1], argv, [speclist], anonfun, errmsg); } function parse(l, f, msg) { @@ -750,28 +787,32 @@ function parse(l, f, msg) { return parse_argv(/* None */0, Sys.argv, l, f, msg); } catch (exn){ - if (exn[1] === Bad) { - Caml_curry.app1(Printf.eprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ]), exn[2]); + if (exn[0] === Bad) { + Caml_curry.app1(Printf.eprintf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + 1: "%s", + length: 2, + tag: 0 + }), exn[1]); return Pervasives.exit(2); } - else if (exn[1] === Help) { - Caml_curry.app1(Printf.printf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ]), exn[2]); + else if (exn[0] === Help) { + Caml_curry.app1(Printf.printf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + 1: "%s", + length: 2, + tag: 0 + }), exn[1]); return Pervasives.exit(0); } else { @@ -785,28 +826,32 @@ function parse_dynamic(l, f, msg) { return parse_argv_dynamic(/* None */0, Sys.argv, l, f, msg); } catch (exn){ - if (exn[1] === Bad) { - Caml_curry.app1(Printf.eprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ]), exn[2]); + if (exn[0] === Bad) { + Caml_curry.app1(Printf.eprintf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + 1: "%s", + length: 2, + tag: 0 + }), exn[1]); return Pervasives.exit(2); } - else if (exn[1] === Help) { - Caml_curry.app1(Printf.printf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ]), exn[2]); + else if (exn[0] === Help) { + Caml_curry.app1(Printf.printf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + 1: "%s", + length: 2, + tag: 0 + }), exn[1]); return Pervasives.exit(0); } else { @@ -845,47 +890,45 @@ function second_word(s) { } function max_arg_len(cur, param) { - var kwd = param[1]; - if (param[2][0] === 11) { + var kwd = param[0]; + if (param[1].tag === 11) { return Pervasives.max(cur, kwd.length); } else { - return Pervasives.max(cur, kwd.length + second_word(param[3])); + return Pervasives.max(cur, kwd.length + second_word(param[2])); } } function align($staropt$star, speclist) { - var limit = $staropt$star ? $staropt$star[1] : Pervasives.max_int; + var limit = $staropt$star ? $staropt$star[0] : Pervasives.max_int; var completed = add_help(speclist); var len = List.fold_left(max_arg_len, 0, completed); var len$1 = Pervasives.min(len, limit); return List.map(function (param) { var len$2 = len$1; var ksd = param; - var spec = ksd[2]; - var kwd = ksd[1]; - if (ksd[3] === "") { + var spec = ksd[1]; + var kwd = ksd[0]; + if (ksd[2] === "") { return ksd; } - else if (spec[0] === 11) { - var msg = ksd[3]; + else if (spec.tag === 11) { + var msg = ksd[2]; var cutcol = second_word(msg); var spaces = $$String.make(Pervasives.max(0, len$2 - cutcol) + 3, /* " " */32); - return [ - /* tuple */0, + return /* tuple */[ kwd, spec, "\n" + (spaces + msg) ]; } else { - var msg$1 = ksd[3]; + var msg$1 = ksd[2]; var cutcol$1 = second_word(msg$1); var kwd_len = kwd.length; var diff = len$2 - kwd_len - cutcol$1; if (diff <= 0) { - return [ - /* tuple */0, + return /* tuple */[ kwd, spec, msg$1 @@ -895,8 +938,7 @@ function align($staropt$star, speclist) { var spaces$1 = $$String.make(diff, /* " " */32); var prefix = $$String.sub(msg$1, 0, cutcol$1); var suffix = $$String.sub(msg$1, cutcol$1, msg$1.length - cutcol$1); - return [ - /* tuple */0, + return /* tuple */[ kwd, spec, prefix + (spaces$1 + suffix) diff --git a/jscomp/stdlib/array.js b/jscomp/stdlib/array.js index 577613fced..67cdfae2e1 100644 --- a/jscomp/stdlib/array.js +++ b/jscomp/stdlib/array.js @@ -9,7 +9,6 @@ function init(l, f) { if (l) { if (l < 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Array.init" ]; @@ -63,7 +62,6 @@ function append(a1, a2) { function sub(a, ofs, len) { if (len < 0 || ofs > a.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Array.sub" ]; @@ -76,7 +74,6 @@ function sub(a, ofs, len) { function fill(a, ofs, len, v) { if (ofs < 0 || len < 0 || ofs > a.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Array.fill" ]; @@ -92,7 +89,6 @@ function fill(a, ofs, len, v) { function blit(a1, ofs1, a2, ofs2, len) { if (len < 0 || ofs1 < 0 || ofs1 > a1.length - len || ofs2 < 0 || ofs2 > a2.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Array.blit" ]; @@ -154,8 +150,7 @@ function to_list(a) { return res; } else { - _res = [ - /* :: */0, + _res = /* :: */[ a[i], res ]; @@ -171,7 +166,7 @@ function list_length(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[2]; + _param = param[1]; _accu = accu + 1; continue ; @@ -184,15 +179,15 @@ function list_length(_accu, _param) { function of_list(l) { if (l) { - var a = Caml_array.caml_make_vect(list_length(0, l), l[1]); + var a = Caml_array.caml_make_vect(list_length(0, l), l[0]); var _i = 1; - var _param = l[2]; + var _param = l[1]; while(true) { var param = _param; var i = _i; if (param) { - a[i] = param[1]; - _param = param[2]; + a[i] = param[0]; + _param = param[1]; _i = i + 1; continue ; @@ -223,11 +218,12 @@ function fold_right(f, a, x) { return r; } -var Bottom = [ - 248, - "Array.Bottom", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Bottom = { + 0: "Array.Bottom", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function sort(cmp, a) { var maxson = function (l, i) { @@ -250,7 +246,6 @@ function sort(cmp, a) { } else { throw [ - 0, Bottom, i ]; @@ -277,8 +272,8 @@ function sort(cmp, a) { }; } catch (exn){ - if (exn[1] === Bottom) { - a[exn[2]] = e; + if (exn[0] === Bottom) { + a[exn[1]] = e; return /* () */0; } else { @@ -300,8 +295,8 @@ function sort(cmp, a) { }; } catch (exn){ - if (exn[1] === Bottom) { - return exn[2]; + if (exn[0] === Bottom) { + return exn[1]; } else { throw exn; @@ -314,10 +309,8 @@ function sort(cmp, a) { var father = (i - 1) / 3 | 0; if (i === father) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "array.ml", 168, 4 diff --git a/jscomp/stdlib/buffer.js b/jscomp/stdlib/buffer.js index baa3dc87de..5d28356649 100644 --- a/jscomp/stdlib/buffer.js +++ b/jscomp/stdlib/buffer.js @@ -13,8 +13,7 @@ function create(n) { var n$1 = n < 1 ? 1 : n; var n$2 = n$1 > Sys.max_string_length ? Sys.max_string_length : n$1; var s = Caml_string.caml_create_string(n$2); - return [ - /* record */0, + return /* record */[ s, 0, n$2, @@ -23,117 +22,112 @@ function create(n) { } function contents(b) { - return Bytes.sub_string(b[1], 0, b[2]); + return Bytes.sub_string(b[0], 0, b[1]); } function to_bytes(b) { - return Bytes.sub(b[1], 0, b[2]); + return Bytes.sub(b[0], 0, b[1]); } function sub(b, ofs, len) { - if (ofs < 0 || len < 0 || ofs > b[2] - len) { + if (ofs < 0 || len < 0 || ofs > b[1] - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Buffer.sub" ]; } else { - return Bytes.sub_string(b[1], ofs, len); + return Bytes.sub_string(b[0], ofs, len); } } function blit(src, srcoff, dst, dstoff, len) { - if (len < 0 || srcoff < 0 || srcoff > src[2] - len || dstoff < 0 || dstoff > dst.length - len) { + if (len < 0 || srcoff < 0 || srcoff > src[1] - len || dstoff < 0 || dstoff > dst.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Buffer.blit" ]; } else { - return Bytes.blit(src[1], srcoff, dst, dstoff, len); + return Bytes.blit(src[0], srcoff, dst, dstoff, len); } } function nth(b, ofs) { - if (ofs < 0 || ofs >= b[2]) { + if (ofs < 0 || ofs >= b[1]) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Buffer.nth" ]; } else { - return b[1][ofs]; + return b[0][ofs]; } } function length(b) { - return b[2]; + return b[1]; } function clear(b) { - b[2] = 0; + b[1] = 0; return /* () */0; } function reset(b) { - b[2] = 0; - b[1] = b[4]; - b[3] = b[1].length; + b[1] = 0; + b[0] = b[3]; + b[2] = b[0].length; return /* () */0; } function resize(b, more) { - var len = b[3]; + var len = b[2]; var new_len = len; - while(b[2] + more > new_len) { + while(b[1] + more > new_len) { new_len = 2 * new_len; }; if (new_len > Sys.max_string_length) { - if (b[2] + more <= Sys.max_string_length) { + if (b[1] + more <= Sys.max_string_length) { new_len = Sys.max_string_length; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Buffer.add: cannot grow buffer" ]; } } var new_buffer = Caml_string.caml_create_string(new_len); - Bytes.blit(b[1], 0, new_buffer, 0, b[2]); - b[1] = new_buffer; - b[3] = new_len; + Bytes.blit(b[0], 0, new_buffer, 0, b[1]); + b[0] = new_buffer; + b[2] = new_len; return /* () */0; } function add_char(b, c) { - var pos = b[2]; - if (pos >= b[3]) { + var pos = b[1]; + if (pos >= b[2]) { resize(b, 1); } - b[1][pos] = c; - b[2] = pos + 1; + b[0][pos] = c; + b[1] = pos + 1; return /* () */0; } function add_substring(b, s, offset, len) { if (offset < 0 || len < 0 || offset + len > s.length) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Buffer.add_substring/add_subbytes" ]; } - var new_position = b[2] + len; - if (new_position > b[3]) { + var new_position = b[1] + len; + if (new_position > b[2]) { resize(b, len); } - Bytes.blit_string(s, offset, b[1], b[2], len); - b[2] = new_position; + Bytes.blit_string(s, offset, b[0], b[1], len); + b[1] = new_position; return /* () */0; } @@ -143,12 +137,12 @@ function add_subbytes(b, s, offset, len) { function add_string(b, s) { var len = s.length; - var new_position = b[2] + len; - if (new_position > b[3]) { + var new_position = b[1] + len; + if (new_position > b[2]) { resize(b, len); } - Bytes.blit_string(s, 0, b[1], b[2], len); - b[2] = new_position; + Bytes.blit_string(s, 0, b[0], b[1], len); + b[1] = new_position; return /* () */0; } @@ -157,37 +151,34 @@ function add_bytes(b, s) { } function add_buffer(b, bs) { - return add_subbytes(b, bs[1], 0, bs[2]); + return add_subbytes(b, bs[0], 0, bs[1]); } function add_channel(b, ic, len) { if (len < 0 || len > Sys.max_string_length) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Buffer.add_channel" ]; } - if (b[2] + len > b[3]) { + if (b[1] + len > b[2]) { resize(b, len); } - Pervasives.really_input(ic, b[1], b[2], len); - b[2] += len; + Pervasives.really_input(ic, b[0], b[1], len); + b[1] += len; return /* () */0; } function output_buffer(oc, b) { - return Pervasives.output(oc, b[1], 0, b[2]); + return Pervasives.output(oc, b[0], 0, b[1]); } function closing(param) { if (param !== 40) { if (param !== 123) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "buffer.ml", 115, 9 @@ -299,8 +290,7 @@ function find_ident(s, start, lim) { if (c !== 40) { if (c !== 123) { var stop = advance_to_non_alpha(s, start + 1); - return [ - /* tuple */0, + return /* tuple */[ $$String.sub(s, start, stop - start), stop ]; @@ -315,8 +305,7 @@ function find_ident(s, start, lim) { if (exit === 1) { var new_start = start + 1; var stop$1 = advance_to_closing(c, closing(c), 0, s, new_start); - return [ - /* tuple */0, + return /* tuple */[ $$String.sub(s, new_start, stop$1 - start - 1), stop$1 + 1 ]; @@ -367,8 +356,8 @@ function add_substitute(b, f, s) { else { var j = i + 1; var match = find_ident(s, j, lim); - add_string(b, Caml_curry.app1(f, match[1])); - _i = match[2]; + add_string(b, Caml_curry.app1(f, match[0])); + _i = match[1]; _previous = /* " " */32; continue ; diff --git a/jscomp/stdlib/bytes.js b/jscomp/stdlib/bytes.js index 310a66d21b..f4e1df0600 100644 --- a/jscomp/stdlib/bytes.js +++ b/jscomp/stdlib/bytes.js @@ -2,9 +2,9 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("./pervasives"); var Char = require("./char"); -var Caml_primitive = require("../runtime/caml_primitive"); var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); var List = require("./list"); @@ -43,7 +43,6 @@ function of_string(s) { function sub(s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.sub / Bytes.sub" ]; @@ -62,17 +61,15 @@ function sub_string(b, ofs, len) { function extend(s, left, right) { var len = s.length + left + right; var r = Caml_string.caml_create_string(len); - var match = left < 0 ? [ - /* tuple */0, + var match = left < 0 ? /* tuple */[ -left, 0 - ] : [ - /* tuple */0, + ] : /* tuple */[ 0, left ]; - var dstoff = match[2]; - var srcoff = match[1]; + var dstoff = match[1]; + var srcoff = match[0]; var cpylen = Pervasives.min(s.length - srcoff, len - dstoff); if (cpylen > 0) { Caml_string.caml_blit_bytes(s, srcoff, r, dstoff, cpylen); @@ -83,7 +80,6 @@ function extend(s, left, right) { function fill(s, ofs, len, c) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.fill / Bytes.fill" ]; @@ -96,7 +92,6 @@ function fill(s, ofs, len, c) { function blit(s1, ofs1, s2, ofs2, len) { if (len < 0 || ofs1 < 0 || ofs1 > s1.length - len || ofs2 < 0 || ofs2 > s2.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Bytes.blit" ]; @@ -109,7 +104,6 @@ function blit(s1, ofs1, s2, ofs2, len) { function blit_string(s1, ofs1, s2, ofs2, len) { if (len < 0 || ofs1 < 0 || ofs1 > s1.length - len || ofs2 < 0 || ofs2 > s2.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.blit / Bytes.blit_string" ]; @@ -135,33 +129,24 @@ function iteri(f, a) { function concat(sep, l) { if (l) { - var hd = l[1]; - var num = [ - 0, - 0 - ]; - var len = [ - 0, - 0 - ]; + var hd = l[0]; + var num = [0]; + var len = [0]; List.iter(function (s) { - ++ num[1]; - len[1] += s.length; + ++ num[0]; + len[0] += s.length; return /* () */0; }, l); - var r = Caml_string.caml_create_string(len[1] + sep.length * (num[1] - 1)); + var r = Caml_string.caml_create_string(len[0] + sep.length * (num[0] - 1)); Caml_string.caml_blit_bytes(hd, 0, r, 0, hd.length); - var pos = [ - 0, - hd.length - ]; + var pos = [hd.length]; List.iter(function (s) { - Caml_string.caml_blit_bytes(sep, 0, r, pos[1], sep.length); - pos[1] += sep.length; - Caml_string.caml_blit_bytes(s, 0, r, pos[1], s.length); - pos[1] += s.length; + Caml_string.caml_blit_bytes(sep, 0, r, pos[0], sep.length); + pos[0] += sep.length; + Caml_string.caml_blit_bytes(s, 0, r, pos[0], s.length); + pos[0] += s.length; return /* () */0; - }, l[2]); + }, l[1]); return r; } else { @@ -402,7 +387,6 @@ function index_from(s, i, c) { var l = s.length; if (i < 0 || i > l) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.index_from / Bytes.index_from" ]; @@ -436,7 +420,6 @@ function rindex(s, c) { function rindex_from(s, i, c) { if (i < -1 || i >= s.length) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.rindex_from / Bytes.rindex_from" ]; @@ -450,7 +433,6 @@ function contains_from(s, i, c) { var l = s.length; if (i < 0 || i > l) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.contains_from / Bytes.contains_from" ]; @@ -478,7 +460,6 @@ function contains(s, c) { function rcontains_from(s, i, c) { if (i < 0 || i >= s.length) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "String.rcontains_from / Bytes.rcontains_from" ]; @@ -500,7 +481,7 @@ function rcontains_from(s, i, c) { } function compare(x, y) { - return Caml_primitive.caml_compare(x, y); + return Caml_obj.caml_compare(x, y); } function unsafe_to_string(prim) { diff --git a/jscomp/stdlib/callback.js b/jscomp/stdlib/callback.js index 8bb2eeba5d..df35b2a9b7 100644 --- a/jscomp/stdlib/callback.js +++ b/jscomp/stdlib/callback.js @@ -1,15 +1,14 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); -var Obj = require("./obj"); +var Obj = require("./obj"); function register(_, _$1) { return /* () */0; } function register_exception(_, exn) { - Caml_obj_runtime.caml_obj_tag(exn) === Obj.object_tag ? exn : exn[0]; + (exn.tag | 0) === Obj.object_tag ? exn : exn[0]; return /* () */0; } diff --git a/jscomp/stdlib/camlinternalFormat.js b/jscomp/stdlib/camlinternalFormat.js index 466eb04ee0..248240f115 100644 --- a/jscomp/stdlib/camlinternalFormat.js +++ b/jscomp/stdlib/camlinternalFormat.js @@ -3,6 +3,7 @@ var Bytes = require("./bytes"); var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Caml_io = require("../runtime/caml_io"); var Caml_float = require("../runtime/caml_float"); var Pervasives = require("./pervasives"); @@ -47,11 +48,12 @@ function is_in_char_set(char_set, c) { function pad_of_pad_opt(pad_opt) { if (pad_opt) { - return [ - /* Lit_padding */0, - /* Right */1, - pad_opt[1] - ]; + return /* Lit_padding */{ + 0: /* Right */1, + 1: pad_opt[0], + length: 2, + tag: 0 + }; } else { return /* No_padding */0; @@ -60,10 +62,11 @@ function pad_of_pad_opt(pad_opt) { function prec_of_prec_opt(prec_opt) { if (prec_opt) { - return [ - /* Lit_precision */0, - prec_opt[1] - ]; + return /* Lit_precision */{ + 0: prec_opt[0], + length: 1, + tag: 0 + }; } else { return /* No_precision */0; @@ -74,162 +77,194 @@ function param_format_of_ignored_format(ign, fmt) { if (typeof ign === "number") { switch (ign) { case 0 : - return [ - /* Param_format_EBB */0, - [ - /* Char */0, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Char */{ + 0: fmt, + length: 1, + tag: 0 + }, + length: 1, + tag: 0 + }; case 1 : - return [ - /* Param_format_EBB */0, - [ - /* Caml_char */1, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Caml_char */{ + 0: fmt, + length: 1, + tag: 1 + }, + length: 1, + tag: 0 + }; case 2 : - return [ - /* Param_format_EBB */0, - [ - /* Bool */9, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Bool */{ + 0: fmt, + length: 1, + tag: 9 + }, + length: 1, + tag: 0 + }; case 3 : - return [ - /* Param_format_EBB */0, - [ - /* Reader */19, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Reader */{ + 0: fmt, + length: 1, + tag: 19 + }, + length: 1, + tag: 0 + }; case 4 : - return [ - /* Param_format_EBB */0, - [ - /* Scan_next_char */22, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Scan_next_char */{ + 0: fmt, + length: 1, + tag: 22 + }, + length: 1, + tag: 0 + }; } } else { - switch (ign[0]) { + switch (ign.tag | 0) { case 0 : - return [ - /* Param_format_EBB */0, - [ - /* String */2, - pad_of_pad_opt(ign[1]), - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* String */{ + 0: pad_of_pad_opt(ign[0]), + 1: fmt, + length: 2, + tag: 2 + }, + length: 1, + tag: 0 + }; case 1 : - return [ - /* Param_format_EBB */0, - [ - /* Caml_string */3, - pad_of_pad_opt(ign[1]), - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Caml_string */{ + 0: pad_of_pad_opt(ign[0]), + 1: fmt, + length: 2, + tag: 3 + }, + length: 1, + tag: 0 + }; case 2 : - return [ - /* Param_format_EBB */0, - [ - /* Int */4, - ign[1], - pad_of_pad_opt(ign[2]), - /* No_precision */0, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Int */{ + 0: ign[0], + 1: pad_of_pad_opt(ign[1]), + 2: /* No_precision */0, + 3: fmt, + length: 4, + tag: 4 + }, + length: 1, + tag: 0 + }; case 3 : - return [ - /* Param_format_EBB */0, - [ - /* Int32 */5, - ign[1], - pad_of_pad_opt(ign[2]), - /* No_precision */0, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Int32 */{ + 0: ign[0], + 1: pad_of_pad_opt(ign[1]), + 2: /* No_precision */0, + 3: fmt, + length: 4, + tag: 5 + }, + length: 1, + tag: 0 + }; case 4 : - return [ - /* Param_format_EBB */0, - [ - /* Nativeint */6, - ign[1], - pad_of_pad_opt(ign[2]), - /* No_precision */0, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Nativeint */{ + 0: ign[0], + 1: pad_of_pad_opt(ign[1]), + 2: /* No_precision */0, + 3: fmt, + length: 4, + tag: 6 + }, + length: 1, + tag: 0 + }; case 5 : - return [ - /* Param_format_EBB */0, - [ - /* Int64 */7, - ign[1], - pad_of_pad_opt(ign[2]), - /* No_precision */0, - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Int64 */{ + 0: ign[0], + 1: pad_of_pad_opt(ign[1]), + 2: /* No_precision */0, + 3: fmt, + length: 4, + tag: 7 + }, + length: 1, + tag: 0 + }; case 6 : - return [ - /* Param_format_EBB */0, - [ - /* Float */8, - /* Float_f */0, - pad_of_pad_opt(ign[1]), - prec_of_prec_opt(ign[2]), - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Float */{ + 0: /* Float_f */0, + 1: pad_of_pad_opt(ign[0]), + 2: prec_of_prec_opt(ign[1]), + 3: fmt, + length: 4, + tag: 8 + }, + length: 1, + tag: 0 + }; case 7 : - return [ - /* Param_format_EBB */0, - [ - /* Format_arg */13, - ign[1], - ign[2], - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Format_arg */{ + 0: ign[0], + 1: ign[1], + 2: fmt, + length: 3, + tag: 13 + }, + length: 1, + tag: 0 + }; case 8 : - return [ - /* Param_format_EBB */0, - [ - /* Format_subst */14, - ign[1], - ign[2], - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Format_subst */{ + 0: ign[0], + 1: ign[1], + 2: fmt, + length: 3, + tag: 14 + }, + length: 1, + tag: 0 + }; case 9 : - return [ - /* Param_format_EBB */0, - [ - /* Scan_char_set */20, - ign[1], - ign[2], - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Scan_char_set */{ + 0: ign[0], + 1: ign[1], + 2: fmt, + length: 3, + tag: 20 + }, + length: 1, + tag: 0 + }; case 10 : - return [ - /* Param_format_EBB */0, - [ - /* Scan_get_counter */21, - ign[1], - fmt - ] - ]; + return /* Param_format_EBB */{ + 0: /* Scan_get_counter */{ + 0: ign[0], + 1: fmt, + length: 2, + tag: 21 + }, + length: 1, + tag: 0 + }; } } @@ -238,13 +273,13 @@ function param_format_of_ignored_format(ign, fmt) { var default_float_precision = 6; function buffer_check_size(buf, overhead) { - var len = buf[2].length; - var min_len = buf[1] + overhead; + var len = buf[1].length; + var min_len = buf[0] + overhead; if (min_len > len) { var new_len = Pervasives.max(len * 2, min_len); var new_str = Caml_string.caml_create_string(new_len); - Bytes.blit(buf[2], 0, new_str, 0, len); - buf[2] = new_str; + Bytes.blit(buf[1], 0, new_str, 0, len); + buf[1] = new_str; return /* () */0; } else { @@ -254,21 +289,21 @@ function buffer_check_size(buf, overhead) { function buffer_add_char(buf, c) { buffer_check_size(buf, 1); - buf[2][buf[1]] = c; - ++ buf[1]; + buf[1][buf[0]] = c; + ++ buf[0]; return /* () */0; } function buffer_add_string(buf, s) { var str_len = s.length; buffer_check_size(buf, str_len); - $$String.blit(s, 0, buf[2], buf[1], str_len); - buf[1] += str_len; + $$String.blit(s, 0, buf[1], buf[0], str_len); + buf[0] += str_len; return /* () */0; } function buffer_contents(buf) { - return Bytes.sub_string(buf[2], 0, buf[1]); + return Bytes.sub_string(buf[1], 0, buf[0]); } function char_of_iconv(iconv) { @@ -339,10 +374,10 @@ function char_of_counter(counter) { function bprint_char_set(buf, char_set) { var print_start = function (set) { var is_alone = function (c) { - var match_001 = Char.chr(c - 1); - var match_002 = Char.chr(c + 1); + var match_000 = Char.chr(c - 1); + var match_001 = Char.chr(c + 1); if (is_in_char_set(set, c)) { - return !(is_in_char_set(set, match_001) && is_in_char_set(set, match_002)); + return !(is_in_char_set(set, match_000) && is_in_char_set(set, match_001)); } else { return /* false */0; @@ -502,7 +537,7 @@ function bprint_ignored_flag(buf, ign_flag) { function bprint_pad_opt(buf, pad_opt) { if (pad_opt) { - return buffer_add_string(buf, "" + pad_opt[1]); + return buffer_add_string(buf, "" + pad_opt[0]); } else { return /* () */0; @@ -514,12 +549,12 @@ function bprint_padding(buf, pad) { return /* () */0; } else { - bprint_padty(buf, pad[1]); - if (pad[0]) { + bprint_padty(buf, pad[0]); + if (pad.tag) { return buffer_add_char(buf, /* "*" */42); } else { - return buffer_add_string(buf, "" + pad[2]); + return buffer_add_string(buf, "" + pad[1]); } } } @@ -535,7 +570,7 @@ function bprint_precision(buf, prec) { } else { buffer_add_char(buf, /* "." */46); - return buffer_add_string(buf, "" + prec[1]); + return buffer_add_string(buf, "" + prec[0]); } } @@ -636,19 +671,19 @@ function string_of_formatting_lit(formatting_lit) { } } else { - switch (formatting_lit[0]) { + switch (formatting_lit.tag | 0) { case 0 : case 1 : - return formatting_lit[1]; + return formatting_lit[0]; case 2 : - return "@" + $$String.make(1, formatting_lit[1]); + return "@" + $$String.make(1, formatting_lit[0]); } } } function string_of_formatting_gen(formatting_gen) { - return formatting_gen[1][2]; + return formatting_gen[0][1]; } function bprint_char_literal(buf, chr) { @@ -674,70 +709,70 @@ function bprint_fmtty(buf, _fmtty) { return /* () */0; } else { - switch (fmtty[0]) { + switch (fmtty.tag | 0) { case 0 : buffer_add_string(buf, "%c"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 1 : buffer_add_string(buf, "%s"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 2 : buffer_add_string(buf, "%i"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 3 : buffer_add_string(buf, "%li"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 4 : buffer_add_string(buf, "%ni"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 5 : buffer_add_string(buf, "%Li"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 6 : buffer_add_string(buf, "%f"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 7 : buffer_add_string(buf, "%B"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 8 : buffer_add_string(buf, "%{"); - bprint_fmtty(buf, fmtty[1]); + bprint_fmtty(buf, fmtty[0]); buffer_add_string(buf, "%}"); - _fmtty = fmtty[2]; + _fmtty = fmtty[1]; continue ; case 9 : buffer_add_string(buf, "%("); - bprint_fmtty(buf, fmtty[1]); + bprint_fmtty(buf, fmtty[0]); buffer_add_string(buf, "%)"); - _fmtty = fmtty[3]; + _fmtty = fmtty[2]; continue ; case 10 : buffer_add_string(buf, "%a"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 11 : buffer_add_string(buf, "%t"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 12 : buffer_add_string(buf, "%?"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 13 : buffer_add_string(buf, "%r"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 14 : buffer_add_string(buf, "%_r"); - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; } @@ -747,7 +782,7 @@ function bprint_fmtty(buf, _fmtty) { function int_of_custom_arity(param) { if (param) { - return 1 + int_of_custom_arity(param[1]); + return 1 + int_of_custom_arity(param[0]); } else { return 0; @@ -764,168 +799,168 @@ function bprint_fmt(buf, fmt) { return /* () */0; } else { - switch (fmt$1[0]) { + switch (fmt$1.tag | 0) { case 0 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, /* "c" */99); _ign_flag = /* false */0; - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 1 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, /* "C" */67); _ign_flag = /* false */0; - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 2 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); - bprint_padding(buf, fmt$1[1]); + bprint_padding(buf, fmt$1[0]); buffer_add_char(buf, /* "s" */115); _ign_flag = /* false */0; - _fmt = fmt$1[2]; + _fmt = fmt$1[1]; continue ; case 3 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); - bprint_padding(buf, fmt$1[1]); + bprint_padding(buf, fmt$1[0]); buffer_add_char(buf, /* "S" */83); _ign_flag = /* false */0; - _fmt = fmt$1[2]; + _fmt = fmt$1[1]; continue ; case 4 : - bprint_int_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3]); + bprint_int_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2]); _ign_flag = /* false */0; - _fmt = fmt$1[4]; + _fmt = fmt$1[3]; continue ; case 5 : - bprint_altint_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3], /* "l" */108); + bprint_altint_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2], /* "l" */108); _ign_flag = /* false */0; - _fmt = fmt$1[4]; + _fmt = fmt$1[3]; continue ; case 6 : - bprint_altint_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3], /* "n" */110); + bprint_altint_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2], /* "n" */110); _ign_flag = /* false */0; - _fmt = fmt$1[4]; + _fmt = fmt$1[3]; continue ; case 7 : - bprint_altint_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3], /* "L" */76); + bprint_altint_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2], /* "L" */76); _ign_flag = /* false */0; - _fmt = fmt$1[4]; + _fmt = fmt$1[3]; continue ; case 8 : - bprint_float_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3]); + bprint_float_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2]); _ign_flag = /* false */0; - _fmt = fmt$1[4]; + _fmt = fmt$1[3]; continue ; case 9 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, /* "B" */66); _ign_flag = /* false */0; - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 10 : buffer_add_string(buf, "%!"); - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 11 : - bprint_string_literal(buf, fmt$1[1]); - _fmt = fmt$1[2]; + bprint_string_literal(buf, fmt$1[0]); + _fmt = fmt$1[1]; continue ; case 12 : - bprint_char_literal(buf, fmt$1[1]); - _fmt = fmt$1[2]; + bprint_char_literal(buf, fmt$1[0]); + _fmt = fmt$1[1]; continue ; case 13 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); - bprint_pad_opt(buf, fmt$1[1]); + bprint_pad_opt(buf, fmt$1[0]); buffer_add_char(buf, /* "{" */123); - bprint_fmtty(buf, fmt$1[2]); + bprint_fmtty(buf, fmt$1[1]); buffer_add_char(buf, /* "%" */37); buffer_add_char(buf, /* "}" */125); _ign_flag = /* false */0; - _fmt = fmt$1[3]; + _fmt = fmt$1[2]; continue ; case 14 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); - bprint_pad_opt(buf, fmt$1[1]); + bprint_pad_opt(buf, fmt$1[0]); buffer_add_char(buf, /* "(" */40); - bprint_fmtty(buf, fmt$1[2]); + bprint_fmtty(buf, fmt$1[1]); buffer_add_char(buf, /* "%" */37); buffer_add_char(buf, /* ")" */41); _ign_flag = /* false */0; - _fmt = fmt$1[3]; + _fmt = fmt$1[2]; continue ; case 15 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, /* "a" */97); _ign_flag = /* false */0; - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 16 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, /* "t" */116); _ign_flag = /* false */0; - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 17 : - bprint_string_literal(buf, string_of_formatting_lit(fmt$1[1])); - _fmt = fmt$1[2]; + bprint_string_literal(buf, string_of_formatting_lit(fmt$1[0])); + _fmt = fmt$1[1]; continue ; case 18 : bprint_string_literal(buf, "@{"); - bprint_string_literal(buf, string_of_formatting_gen(fmt$1[1])); - _fmt = fmt$1[2]; + bprint_string_literal(buf, string_of_formatting_gen(fmt$1[0])); + _fmt = fmt$1[1]; continue ; case 19 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, /* "r" */114); _ign_flag = /* false */0; - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 20 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); - bprint_pad_opt(buf, fmt$1[1]); - bprint_char_set(buf, fmt$1[2]); + bprint_pad_opt(buf, fmt$1[0]); + bprint_char_set(buf, fmt$1[1]); _ign_flag = /* false */0; - _fmt = fmt$1[3]; + _fmt = fmt$1[2]; continue ; case 21 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, char_of_counter(fmt$1[1])); + buffer_add_char(buf, char_of_counter(fmt$1[0])); _ign_flag = /* false */0; - _fmt = fmt$1[2]; + _fmt = fmt$1[1]; continue ; case 22 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); bprint_string_literal(buf, "0c"); _ign_flag = /* false */0; - _fmt = fmt$1[1]; + _fmt = fmt$1[0]; continue ; case 23 : - var match = param_format_of_ignored_format(fmt$1[1], fmt$1[2]); + var match = param_format_of_ignored_format(fmt$1[0], fmt$1[1]); _ign_flag = /* true */1; - _fmt = match[1]; + _fmt = match[0]; continue ; case 24 : - for(var _i = 1 ,_i_finish = int_of_custom_arity(fmt$1[1]); _i<= _i_finish; ++_i){ + for(var _i = 1 ,_i_finish = int_of_custom_arity(fmt$1[0]); _i<= _i_finish; ++_i){ buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, /* "?" */63); } _ign_flag = /* false */0; - _fmt = fmt$1[3]; + _fmt = fmt$1[2]; continue ; } @@ -934,8 +969,7 @@ function bprint_fmt(buf, fmt) { } function string_of_fmt(fmt) { - var buf = [ - /* record */0, + var buf = /* record */[ 0, new Array(16) ]; @@ -948,85 +982,100 @@ function symm(param) { return /* End_of_fmtty */0; } else { - switch (param[0]) { + switch (param.tag | 0) { case 0 : - return [ - /* Char_ty */0, - symm(param[1]) - ]; + return /* Char_ty */{ + 0: symm(param[0]), + length: 1, + tag: 0 + }; case 1 : - return [ - /* String_ty */1, - symm(param[1]) - ]; + return /* String_ty */{ + 0: symm(param[0]), + length: 1, + tag: 1 + }; case 2 : - return [ - /* Int_ty */2, - symm(param[1]) - ]; + return /* Int_ty */{ + 0: symm(param[0]), + length: 1, + tag: 2 + }; case 3 : - return [ - /* Int32_ty */3, - symm(param[1]) - ]; + return /* Int32_ty */{ + 0: symm(param[0]), + length: 1, + tag: 3 + }; case 4 : - return [ - /* Nativeint_ty */4, - symm(param[1]) - ]; + return /* Nativeint_ty */{ + 0: symm(param[0]), + length: 1, + tag: 4 + }; case 5 : - return [ - /* Int64_ty */5, - symm(param[1]) - ]; + return /* Int64_ty */{ + 0: symm(param[0]), + length: 1, + tag: 5 + }; case 6 : - return [ - /* Float_ty */6, - symm(param[1]) - ]; + return /* Float_ty */{ + 0: symm(param[0]), + length: 1, + tag: 6 + }; case 7 : - return [ - /* Bool_ty */7, - symm(param[1]) - ]; + return /* Bool_ty */{ + 0: symm(param[0]), + length: 1, + tag: 7 + }; case 8 : - return [ - /* Format_arg_ty */8, - param[1], - symm(param[2]) - ]; + return /* Format_arg_ty */{ + 0: param[0], + 1: symm(param[1]), + length: 2, + tag: 8 + }; case 9 : - return [ - /* Format_subst_ty */9, - param[2], - param[1], - symm(param[3]) - ]; + return /* Format_subst_ty */{ + 0: param[1], + 1: param[0], + 2: symm(param[2]), + length: 3, + tag: 9 + }; case 10 : - return [ - /* Alpha_ty */10, - symm(param[1]) - ]; + return /* Alpha_ty */{ + 0: symm(param[0]), + length: 1, + tag: 10 + }; case 11 : - return [ - /* Theta_ty */11, - symm(param[1]) - ]; + return /* Theta_ty */{ + 0: symm(param[0]), + length: 1, + tag: 11 + }; case 12 : - return [ - /* Any_ty */12, - symm(param[1]) - ]; + return /* Any_ty */{ + 0: symm(param[0]), + length: 1, + tag: 12 + }; case 13 : - return [ - /* Reader_ty */13, - symm(param[1]) - ]; + return /* Reader_ty */{ + 0: symm(param[0]), + length: 1, + tag: 13 + }; case 14 : - return [ - /* Ignored_reader_ty */14, - symm(param[1]) - ]; + return /* Ignored_reader_ty */{ + 0: symm(param[0]), + length: 1, + tag: 14 + }; } } @@ -1034,8 +1083,7 @@ function symm(param) { function fmtty_rel_det(param) { if (typeof param === "number") { - return [ - /* tuple */0, + return /* tuple */[ function () { return /* Refl */0; }, @@ -1051,13 +1099,12 @@ function fmtty_rel_det(param) { ]; } else { - switch (param[0]) { + switch (param.tag | 0) { case 0 : - var match = fmtty_rel_det(param[1]); - var af = match[2]; - var fa = match[1]; - return [ - /* tuple */0, + var match = fmtty_rel_det(param[0]); + var af = match[1]; + var fa = match[0]; + return /* tuple */[ function () { Caml_curry.app1(fa, /* Refl */0); return /* Refl */0; @@ -1066,15 +1113,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af, /* Refl */0); return /* Refl */0; }, - match[3], - match[4] + match[2], + match[3] ]; case 1 : - var match$1 = fmtty_rel_det(param[1]); - var af$1 = match$1[2]; - var fa$1 = match$1[1]; - return [ - /* tuple */0, + var match$1 = fmtty_rel_det(param[0]); + var af$1 = match$1[1]; + var fa$1 = match$1[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$1, /* Refl */0); return /* Refl */0; @@ -1083,15 +1129,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$1, /* Refl */0); return /* Refl */0; }, - match$1[3], - match$1[4] + match$1[2], + match$1[3] ]; case 2 : - var match$2 = fmtty_rel_det(param[1]); - var af$2 = match$2[2]; - var fa$2 = match$2[1]; - return [ - /* tuple */0, + var match$2 = fmtty_rel_det(param[0]); + var af$2 = match$2[1]; + var fa$2 = match$2[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$2, /* Refl */0); return /* Refl */0; @@ -1100,15 +1145,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$2, /* Refl */0); return /* Refl */0; }, - match$2[3], - match$2[4] + match$2[2], + match$2[3] ]; case 3 : - var match$3 = fmtty_rel_det(param[1]); - var af$3 = match$3[2]; - var fa$3 = match$3[1]; - return [ - /* tuple */0, + var match$3 = fmtty_rel_det(param[0]); + var af$3 = match$3[1]; + var fa$3 = match$3[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$3, /* Refl */0); return /* Refl */0; @@ -1117,15 +1161,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$3, /* Refl */0); return /* Refl */0; }, - match$3[3], - match$3[4] + match$3[2], + match$3[3] ]; case 4 : - var match$4 = fmtty_rel_det(param[1]); - var af$4 = match$4[2]; - var fa$4 = match$4[1]; - return [ - /* tuple */0, + var match$4 = fmtty_rel_det(param[0]); + var af$4 = match$4[1]; + var fa$4 = match$4[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$4, /* Refl */0); return /* Refl */0; @@ -1134,15 +1177,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$4, /* Refl */0); return /* Refl */0; }, - match$4[3], - match$4[4] + match$4[2], + match$4[3] ]; case 5 : - var match$5 = fmtty_rel_det(param[1]); - var af$5 = match$5[2]; - var fa$5 = match$5[1]; - return [ - /* tuple */0, + var match$5 = fmtty_rel_det(param[0]); + var af$5 = match$5[1]; + var fa$5 = match$5[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$5, /* Refl */0); return /* Refl */0; @@ -1151,15 +1193,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$5, /* Refl */0); return /* Refl */0; }, - match$5[3], - match$5[4] + match$5[2], + match$5[3] ]; case 6 : - var match$6 = fmtty_rel_det(param[1]); - var af$6 = match$6[2]; - var fa$6 = match$6[1]; - return [ - /* tuple */0, + var match$6 = fmtty_rel_det(param[0]); + var af$6 = match$6[1]; + var fa$6 = match$6[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$6, /* Refl */0); return /* Refl */0; @@ -1168,15 +1209,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$6, /* Refl */0); return /* Refl */0; }, - match$6[3], - match$6[4] + match$6[2], + match$6[3] ]; case 7 : - var match$7 = fmtty_rel_det(param[1]); - var af$7 = match$7[2]; - var fa$7 = match$7[1]; - return [ - /* tuple */0, + var match$7 = fmtty_rel_det(param[0]); + var af$7 = match$7[1]; + var fa$7 = match$7[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$7, /* Refl */0); return /* Refl */0; @@ -1185,15 +1225,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$7, /* Refl */0); return /* Refl */0; }, - match$7[3], - match$7[4] + match$7[2], + match$7[3] ]; case 8 : - var match$8 = fmtty_rel_det(param[2]); - var af$8 = match$8[2]; - var fa$8 = match$8[1]; - return [ - /* tuple */0, + var match$8 = fmtty_rel_det(param[1]); + var af$8 = match$8[1]; + var fa$8 = match$8[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$8, /* Refl */0); return /* Refl */0; @@ -1202,23 +1241,22 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$8, /* Refl */0); return /* Refl */0; }, - match$8[3], - match$8[4] + match$8[2], + match$8[3] ]; case 9 : - var match$9 = fmtty_rel_det(param[3]); - var de = match$9[4]; - var ed = match$9[3]; - var af$9 = match$9[2]; - var fa$9 = match$9[1]; - var ty = trans(symm(param[1]), param[2]); + var match$9 = fmtty_rel_det(param[2]); + var de = match$9[3]; + var ed = match$9[2]; + var af$9 = match$9[1]; + var fa$9 = match$9[0]; + var ty = trans(symm(param[0]), param[1]); var match$10 = fmtty_rel_det(ty); - var jd = match$10[4]; - var dj = match$10[3]; - var ga = match$10[2]; - var ag = match$10[1]; - return [ - /* tuple */0, + var jd = match$10[3]; + var dj = match$10[2]; + var ga = match$10[1]; + var ag = match$10[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$9, /* Refl */0); Caml_curry.app1(ag, /* Refl */0); @@ -1241,11 +1279,10 @@ function fmtty_rel_det(param) { } ]; case 10 : - var match$11 = fmtty_rel_det(param[1]); - var af$10 = match$11[2]; - var fa$10 = match$11[1]; - return [ - /* tuple */0, + var match$11 = fmtty_rel_det(param[0]); + var af$10 = match$11[1]; + var fa$10 = match$11[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$10, /* Refl */0); return /* Refl */0; @@ -1254,15 +1291,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$10, /* Refl */0); return /* Refl */0; }, - match$11[3], - match$11[4] + match$11[2], + match$11[3] ]; case 11 : - var match$12 = fmtty_rel_det(param[1]); - var af$11 = match$12[2]; - var fa$11 = match$12[1]; - return [ - /* tuple */0, + var match$12 = fmtty_rel_det(param[0]); + var af$11 = match$12[1]; + var fa$11 = match$12[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$11, /* Refl */0); return /* Refl */0; @@ -1271,15 +1307,14 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$11, /* Refl */0); return /* Refl */0; }, - match$12[3], - match$12[4] + match$12[2], + match$12[3] ]; case 12 : - var match$13 = fmtty_rel_det(param[1]); - var af$12 = match$13[2]; - var fa$12 = match$13[1]; - return [ - /* tuple */0, + var match$13 = fmtty_rel_det(param[0]); + var af$12 = match$13[1]; + var fa$12 = match$13[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$12, /* Refl */0); return /* Refl */0; @@ -1288,17 +1323,16 @@ function fmtty_rel_det(param) { Caml_curry.app1(af$12, /* Refl */0); return /* Refl */0; }, - match$13[3], - match$13[4] + match$13[2], + match$13[3] ]; case 13 : - var match$14 = fmtty_rel_det(param[1]); - var de$1 = match$14[4]; - var ed$1 = match$14[3]; - var af$13 = match$14[2]; - var fa$13 = match$14[1]; - return [ - /* tuple */0, + var match$14 = fmtty_rel_det(param[0]); + var de$1 = match$14[3]; + var ed$1 = match$14[2]; + var af$13 = match$14[1]; + var fa$13 = match$14[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$13, /* Refl */0); return /* Refl */0; @@ -1317,13 +1351,12 @@ function fmtty_rel_det(param) { } ]; case 14 : - var match$15 = fmtty_rel_det(param[1]); - var de$2 = match$15[4]; - var ed$2 = match$15[3]; - var af$14 = match$15[2]; - var fa$14 = match$15[1]; - return [ - /* tuple */0, + var match$15 = fmtty_rel_det(param[0]); + var de$2 = match$15[3]; + var ed$2 = match$15[2]; + var af$14 = match$15[1]; + var fa$14 = match$15[0]; + return /* tuple */[ function () { Caml_curry.app1(fa$14, /* Refl */0); return /* Refl */0; @@ -1352,10 +1385,8 @@ function trans(ty1, ty2) { if (typeof ty2 === "number") { if (ty2) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 816, 23 @@ -1367,7 +1398,7 @@ function trans(ty1, ty2) { } } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 8 : exit = 6; break; @@ -1391,10 +1422,8 @@ function trans(ty1, ty2) { break; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 816, 23 @@ -1404,18 +1433,19 @@ function trans(ty1, ty2) { } } else { - switch (ty1[0]) { + switch (ty1.tag | 0) { case 0 : if (typeof ty2 === "number") { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 0 : - return [ - /* Char_ty */0, - trans(ty1[1], ty2[1]) - ]; + return /* Char_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 0 + }; case 8 : exit = 6; break; @@ -1446,12 +1476,13 @@ function trans(ty1, ty2) { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 1 : - return [ - /* String_ty */1, - trans(ty1[1], ty2[1]) - ]; + return /* String_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 1 + }; case 8 : exit = 6; break; @@ -1482,12 +1513,13 @@ function trans(ty1, ty2) { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 2 : - return [ - /* Int_ty */2, - trans(ty1[1], ty2[1]) - ]; + return /* Int_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 2 + }; case 8 : exit = 6; break; @@ -1518,12 +1550,13 @@ function trans(ty1, ty2) { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 3 : - return [ - /* Int32_ty */3, - trans(ty1[1], ty2[1]) - ]; + return /* Int32_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 3 + }; case 8 : exit = 6; break; @@ -1554,12 +1587,13 @@ function trans(ty1, ty2) { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 4 : - return [ - /* Nativeint_ty */4, - trans(ty1[1], ty2[1]) - ]; + return /* Nativeint_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 4 + }; case 8 : exit = 6; break; @@ -1590,12 +1624,13 @@ function trans(ty1, ty2) { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 5 : - return [ - /* Int64_ty */5, - trans(ty1[1], ty2[1]) - ]; + return /* Int64_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 5 + }; case 8 : exit = 6; break; @@ -1626,12 +1661,13 @@ function trans(ty1, ty2) { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 6 : - return [ - /* Float_ty */6, - trans(ty1[1], ty2[1]) - ]; + return /* Float_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 6 + }; case 8 : exit = 6; break; @@ -1662,12 +1698,13 @@ function trans(ty1, ty2) { exit = 8; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 7 : - return [ - /* Bool_ty */7, - trans(ty1[1], ty2[1]) - ]; + return /* Bool_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 7 + }; case 8 : exit = 6; break; @@ -1696,10 +1733,8 @@ function trans(ty1, ty2) { case 8 : if (typeof ty2 === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 802, 26 @@ -1707,13 +1742,14 @@ function trans(ty1, ty2) { ]; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 8 : - return [ - /* Format_arg_ty */8, - trans(ty1[1], ty2[1]), - trans(ty1[2], ty2[2]) - ]; + return /* Format_arg_ty */{ + 0: trans(ty1[0], ty2[0]), + 1: trans(ty1[1], ty2[1]), + length: 2, + tag: 8 + }; case 10 : exit = 1; break; @@ -1731,10 +1767,8 @@ function trans(ty1, ty2) { break; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 802, 26 @@ -1746,10 +1780,8 @@ function trans(ty1, ty2) { case 9 : if (typeof ty2 === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 812, 28 @@ -1757,21 +1789,22 @@ function trans(ty1, ty2) { ]; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 8 : exit = 6; break; case 9 : - var ty = trans(symm(ty1[2]), ty2[1]); + var ty = trans(symm(ty1[1]), ty2[0]); var match = fmtty_rel_det(ty); - Caml_curry.app1(match[2], /* Refl */0); - Caml_curry.app1(match[4], /* Refl */0); - return [ - /* Format_subst_ty */9, - ty1[1], - ty2[2], - trans(ty1[3], ty2[3]) - ]; + Caml_curry.app1(match[1], /* Refl */0); + Caml_curry.app1(match[3], /* Refl */0); + return /* Format_subst_ty */{ + 0: ty1[0], + 1: ty2[1], + 2: trans(ty1[2], ty2[2]), + length: 3, + tag: 9 + }; case 10 : exit = 1; break; @@ -1789,10 +1822,8 @@ function trans(ty1, ty2) { break; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 812, 28 @@ -1804,28 +1835,25 @@ function trans(ty1, ty2) { case 10 : if (typeof ty2 === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 780, 21 ] ]; } - else if (ty2[0] === 10) { - return [ - /* Alpha_ty */10, - trans(ty1[1], ty2[1]) - ]; + else if (ty2.tag === 10) { + return /* Alpha_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 10 + }; } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 780, 21 @@ -1836,10 +1864,8 @@ function trans(ty1, ty2) { case 11 : if (typeof ty2 === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 784, 21 @@ -1847,21 +1873,20 @@ function trans(ty1, ty2) { ]; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 10 : exit = 1; break; case 11 : - return [ - /* Theta_ty */11, - trans(ty1[1], ty2[1]) - ]; + return /* Theta_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 11 + }; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 784, 21 @@ -1873,10 +1898,8 @@ function trans(ty1, ty2) { case 12 : if (typeof ty2 === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 788, 19 @@ -1884,7 +1907,7 @@ function trans(ty1, ty2) { ]; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 10 : exit = 1; break; @@ -1892,16 +1915,15 @@ function trans(ty1, ty2) { exit = 2; break; case 12 : - return [ - /* Any_ty */12, - trans(ty1[1], ty2[1]) - ]; + return /* Any_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 12 + }; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 788, 19 @@ -1913,10 +1935,8 @@ function trans(ty1, ty2) { case 13 : if (typeof ty2 === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 792, 22 @@ -1924,7 +1944,7 @@ function trans(ty1, ty2) { ]; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 10 : exit = 1; break; @@ -1935,16 +1955,15 @@ function trans(ty1, ty2) { exit = 3; break; case 13 : - return [ - /* Reader_ty */13, - trans(ty1[1], ty2[1]) - ]; + return /* Reader_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 13 + }; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 792, 22 @@ -1956,10 +1975,8 @@ function trans(ty1, ty2) { case 14 : if (typeof ty2 === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 797, 30 @@ -1967,7 +1984,7 @@ function trans(ty1, ty2) { ]; } else { - switch (ty2[0]) { + switch (ty2.tag | 0) { case 10 : exit = 1; break; @@ -1981,16 +1998,15 @@ function trans(ty1, ty2) { exit = 4; break; case 14 : - return [ - /* Ignored_reader_ty */14, - trans(ty1[1], ty2[1]) - ]; + return /* Ignored_reader_ty */{ + 0: trans(ty1[0], ty2[0]), + length: 1, + tag: 14 + }; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 797, 30 @@ -2005,10 +2021,8 @@ function trans(ty1, ty2) { switch (exit) { case 1 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 781, 21 @@ -2016,10 +2030,8 @@ function trans(ty1, ty2) { ]; case 2 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 785, 21 @@ -2027,10 +2039,8 @@ function trans(ty1, ty2) { ]; case 3 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 789, 19 @@ -2038,10 +2048,8 @@ function trans(ty1, ty2) { ]; case 4 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 793, 22 @@ -2049,10 +2057,8 @@ function trans(ty1, ty2) { ]; case 5 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 798, 30 @@ -2060,10 +2066,8 @@ function trans(ty1, ty2) { ]; case 6 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 803, 26 @@ -2071,10 +2075,8 @@ function trans(ty1, ty2) { ]; case 7 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 813, 28 @@ -2082,10 +2084,8 @@ function trans(ty1, ty2) { ]; case 8 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 817, 23 @@ -2096,7 +2096,7 @@ function trans(ty1, ty2) { } function fmtty_of_formatting_gen(formatting_gen) { - return fmtty_of_fmt(formatting_gen[1][1]); + return fmtty_of_fmt(formatting_gen[0][0]); } function fmtty_of_fmt(_fmtty) { @@ -2106,119 +2106,135 @@ function fmtty_of_fmt(_fmtty) { return /* End_of_fmtty */0; } else { - switch (fmtty[0]) { + switch (fmtty.tag | 0) { case 2 : case 3 : - return fmtty_of_padding_fmtty(fmtty[1], [ - /* String_ty */1, - fmtty_of_fmt(fmtty[2]) - ]); + return fmtty_of_padding_fmtty(fmtty[0], /* String_ty */{ + 0: fmtty_of_fmt(fmtty[1]), + length: 1, + tag: 1 + }); case 4 : - var ty_rest = fmtty_of_fmt(fmtty[4]); - var prec_ty = fmtty_of_precision_fmtty(fmtty[3], [ - /* Int_ty */2, - ty_rest - ]); - return fmtty_of_padding_fmtty(fmtty[2], prec_ty); + var ty_rest = fmtty_of_fmt(fmtty[3]); + var prec_ty = fmtty_of_precision_fmtty(fmtty[2], /* Int_ty */{ + 0: ty_rest, + length: 1, + tag: 2 + }); + return fmtty_of_padding_fmtty(fmtty[1], prec_ty); case 5 : - var ty_rest$1 = fmtty_of_fmt(fmtty[4]); - var prec_ty$1 = fmtty_of_precision_fmtty(fmtty[3], [ - /* Int32_ty */3, - ty_rest$1 - ]); - return fmtty_of_padding_fmtty(fmtty[2], prec_ty$1); + var ty_rest$1 = fmtty_of_fmt(fmtty[3]); + var prec_ty$1 = fmtty_of_precision_fmtty(fmtty[2], /* Int32_ty */{ + 0: ty_rest$1, + length: 1, + tag: 3 + }); + return fmtty_of_padding_fmtty(fmtty[1], prec_ty$1); case 6 : - var ty_rest$2 = fmtty_of_fmt(fmtty[4]); - var prec_ty$2 = fmtty_of_precision_fmtty(fmtty[3], [ - /* Nativeint_ty */4, - ty_rest$2 - ]); - return fmtty_of_padding_fmtty(fmtty[2], prec_ty$2); + var ty_rest$2 = fmtty_of_fmt(fmtty[3]); + var prec_ty$2 = fmtty_of_precision_fmtty(fmtty[2], /* Nativeint_ty */{ + 0: ty_rest$2, + length: 1, + tag: 4 + }); + return fmtty_of_padding_fmtty(fmtty[1], prec_ty$2); case 7 : - var ty_rest$3 = fmtty_of_fmt(fmtty[4]); - var prec_ty$3 = fmtty_of_precision_fmtty(fmtty[3], [ - /* Int64_ty */5, - ty_rest$3 - ]); - return fmtty_of_padding_fmtty(fmtty[2], prec_ty$3); + var ty_rest$3 = fmtty_of_fmt(fmtty[3]); + var prec_ty$3 = fmtty_of_precision_fmtty(fmtty[2], /* Int64_ty */{ + 0: ty_rest$3, + length: 1, + tag: 5 + }); + return fmtty_of_padding_fmtty(fmtty[1], prec_ty$3); case 8 : - var ty_rest$4 = fmtty_of_fmt(fmtty[4]); - var prec_ty$4 = fmtty_of_precision_fmtty(fmtty[3], [ - /* Float_ty */6, - ty_rest$4 - ]); - return fmtty_of_padding_fmtty(fmtty[2], prec_ty$4); + var ty_rest$4 = fmtty_of_fmt(fmtty[3]); + var prec_ty$4 = fmtty_of_precision_fmtty(fmtty[2], /* Float_ty */{ + 0: ty_rest$4, + length: 1, + tag: 6 + }); + return fmtty_of_padding_fmtty(fmtty[1], prec_ty$4); case 9 : - return [ - /* Bool_ty */7, - fmtty_of_fmt(fmtty[1]) - ]; + return /* Bool_ty */{ + 0: fmtty_of_fmt(fmtty[0]), + length: 1, + tag: 7 + }; case 10 : - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 13 : - return [ - /* Format_arg_ty */8, - fmtty[2], - fmtty_of_fmt(fmtty[3]) - ]; + return /* Format_arg_ty */{ + 0: fmtty[1], + 1: fmtty_of_fmt(fmtty[2]), + length: 2, + tag: 8 + }; case 14 : - var ty = fmtty[2]; - return [ - /* Format_subst_ty */9, - ty, - ty, - fmtty_of_fmt(fmtty[3]) - ]; + var ty = fmtty[1]; + return /* Format_subst_ty */{ + 0: ty, + 1: ty, + 2: fmtty_of_fmt(fmtty[2]), + length: 3, + tag: 9 + }; case 15 : - return [ - /* Alpha_ty */10, - fmtty_of_fmt(fmtty[1]) - ]; + return /* Alpha_ty */{ + 0: fmtty_of_fmt(fmtty[0]), + length: 1, + tag: 10 + }; case 16 : - return [ - /* Theta_ty */11, - fmtty_of_fmt(fmtty[1]) - ]; + return /* Theta_ty */{ + 0: fmtty_of_fmt(fmtty[0]), + length: 1, + tag: 11 + }; case 11 : case 12 : case 17 : - _fmtty = fmtty[2]; + _fmtty = fmtty[1]; continue ; case 18 : - return CamlinternalFormatBasics.concat_fmtty(fmtty_of_formatting_gen(fmtty[1]), fmtty_of_fmt(fmtty[2])); + return CamlinternalFormatBasics.concat_fmtty(fmtty_of_formatting_gen(fmtty[0]), fmtty_of_fmt(fmtty[1])); case 19 : - return [ - /* Reader_ty */13, - fmtty_of_fmt(fmtty[1]) - ]; + return /* Reader_ty */{ + 0: fmtty_of_fmt(fmtty[0]), + length: 1, + tag: 13 + }; case 20 : - return [ - /* String_ty */1, - fmtty_of_fmt(fmtty[3]) - ]; + return /* String_ty */{ + 0: fmtty_of_fmt(fmtty[2]), + length: 1, + tag: 1 + }; case 21 : - return [ - /* Int_ty */2, - fmtty_of_fmt(fmtty[2]) - ]; + return /* Int_ty */{ + 0: fmtty_of_fmt(fmtty[1]), + length: 1, + tag: 2 + }; case 0 : case 1 : case 22 : - return [ - /* Char_ty */0, - fmtty_of_fmt(fmtty[1]) - ]; + return /* Char_ty */{ + 0: fmtty_of_fmt(fmtty[0]), + length: 1, + tag: 0 + }; case 23 : - var ign = fmtty[1]; - var fmt = fmtty[2]; + var ign = fmtty[0]; + var fmt = fmtty[1]; if (typeof ign === "number") { switch (ign) { case 3 : - return [ - /* Ignored_reader_ty */14, - fmtty_of_fmt(fmt) - ]; + return /* Ignored_reader_ty */{ + 0: fmtty_of_fmt(fmt), + length: 1, + tag: 14 + }; case 0 : case 1 : case 2 : @@ -2228,9 +2244,9 @@ function fmtty_of_fmt(_fmtty) { } } else { - switch (ign[0]) { + switch (ign.tag | 0) { case 8 : - return CamlinternalFormatBasics.concat_fmtty(ign[2], fmtty_of_fmt(fmt)); + return CamlinternalFormatBasics.concat_fmtty(ign[1], fmtty_of_fmt(fmt)); case 0 : case 1 : case 2 : @@ -2246,7 +2262,7 @@ function fmtty_of_fmt(_fmtty) { } } case 24 : - return fmtty_of_custom(fmtty[1], fmtty_of_fmt(fmtty[3])); + return fmtty_of_custom(fmtty[0], fmtty_of_fmt(fmtty[2])); } } @@ -2255,10 +2271,11 @@ function fmtty_of_fmt(_fmtty) { function fmtty_of_custom(arity, fmtty) { if (arity) { - return [ - /* Any_ty */12, - fmtty_of_custom(arity[1], fmtty) - ]; + return /* Any_ty */{ + 0: fmtty_of_custom(arity[0], fmtty), + length: 1, + tag: 12 + }; } else { return fmtty; @@ -2266,71 +2283,79 @@ function fmtty_of_custom(arity, fmtty) { } function fmtty_of_padding_fmtty(pad, fmtty) { - if (typeof pad === "number" || !pad[0]) { + if (typeof pad === "number" || !pad.tag) { return fmtty; } else { - return [ - /* Int_ty */2, - fmtty - ]; + return /* Int_ty */{ + 0: fmtty, + length: 1, + tag: 2 + }; } } function fmtty_of_precision_fmtty(prec, fmtty) { if (typeof prec === "number" && prec !== 0) { - return [ - /* Int_ty */2, - fmtty - ]; + return /* Int_ty */{ + 0: fmtty, + length: 1, + tag: 2 + }; } else { return fmtty; } } -var Type_mismatch = [ - 248, - "CamlinternalFormat.Type_mismatch", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Type_mismatch = { + 0: "CamlinternalFormat.Type_mismatch", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function type_padding(pad, fmtty) { if (typeof pad === "number") { - return [ - /* Padding_fmtty_EBB */0, - /* No_padding */0, - fmtty - ]; + return /* Padding_fmtty_EBB */{ + 0: /* No_padding */0, + 1: fmtty, + length: 2, + tag: 0 + }; } - else if (pad[0]) { + else if (pad.tag) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 2) { - return [ - /* Padding_fmtty_EBB */0, - [ - /* Arg_padding */1, - pad[1] - ], - fmtty[1] - ]; + else if (fmtty.tag === 2) { + return /* Padding_fmtty_EBB */{ + 0: /* Arg_padding */{ + 0: pad[0], + length: 1, + tag: 1 + }, + 1: fmtty[0], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } } else { - return [ - /* Padding_fmtty_EBB */0, - [ - /* Lit_padding */0, - pad[1], - pad[2] - ], - fmtty - ]; + return /* Padding_fmtty_EBB */{ + 0: /* Lit_padding */{ + 0: pad[0], + 1: pad[1], + length: 2, + tag: 0 + }, + 1: fmtty, + length: 2, + tag: 0 + }; } } @@ -2338,48 +2363,52 @@ function type_padprec(pad, prec, fmtty) { var match = type_padding(pad, fmtty); if (typeof prec === "number") { if (prec !== 0) { - var match$1 = match[2]; + var match$1 = match[1]; if (typeof match$1 === "number") { throw Type_mismatch; } - else if (match$1[0] === 2) { - return [ - /* Padprec_fmtty_EBB */0, - match[1], - /* Arg_precision */1, - match$1[1] - ]; + else if (match$1.tag === 2) { + return /* Padprec_fmtty_EBB */{ + 0: match[0], + 1: /* Arg_precision */1, + 2: match$1[0], + length: 3, + tag: 0 + }; } else { throw Type_mismatch; } } else { - return [ - /* Padprec_fmtty_EBB */0, - match[1], - /* No_precision */0, - match[2] - ]; + return /* Padprec_fmtty_EBB */{ + 0: match[0], + 1: /* No_precision */0, + 2: match[1], + length: 3, + tag: 0 + }; } } else { - return [ - /* Padprec_fmtty_EBB */0, - match[1], - [ - /* Lit_precision */0, - prec[1] - ], - match[2] - ]; + return /* Padprec_fmtty_EBB */{ + 0: match[0], + 1: /* Lit_precision */{ + 0: prec[0], + length: 1, + tag: 0 + }, + 2: match[1], + length: 3, + tag: 0 + }; } } function type_format(fmt, fmtty) { var match = type_format_gen(fmt, fmtty); - if (typeof match[2] === "number") { - return match[1]; + if (typeof match[1] === "number") { + return match[0]; } else { throw Type_mismatch; @@ -2388,211 +2417,230 @@ function type_format(fmt, fmtty) { function type_format_gen(fmt, fmtty) { if (typeof fmt === "number") { - return [ - /* Fmt_fmtty_EBB */0, - /* End_of_format */0, - fmtty - ]; + return /* Fmt_fmtty_EBB */{ + 0: /* End_of_format */0, + 1: fmtty, + length: 2, + tag: 0 + }; } else { - switch (fmt[0]) { + switch (fmt.tag | 0) { case 0 : if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0]) { + else if (fmtty.tag) { throw Type_mismatch; } else { - var match = type_format_gen(fmt[1], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Char */0, - match[1] - ], - match[2] - ]; + var match = type_format_gen(fmt[0], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Char */{ + 0: match[0], + length: 1, + tag: 0 + }, + 1: match[1], + length: 2, + tag: 0 + }; } break; case 1 : if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0]) { + else if (fmtty.tag) { throw Type_mismatch; } else { - var match$1 = type_format_gen(fmt[1], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Caml_char */1, - match$1[1] - ], - match$1[2] - ]; + var match$1 = type_format_gen(fmt[0], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Caml_char */{ + 0: match$1[0], + length: 1, + tag: 1 + }, + 1: match$1[1], + length: 2, + tag: 0 + }; } break; case 2 : - var match$2 = type_padding(fmt[1], fmtty); - var match$3 = match$2[2]; + var match$2 = type_padding(fmt[0], fmtty); + var match$3 = match$2[1]; if (typeof match$3 === "number") { throw Type_mismatch; } - else if (match$3[0] === 1) { - var match$4 = type_format_gen(fmt[2], match$3[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* String */2, - match$2[1], - match$4[1] - ], - match$4[2] - ]; + else if (match$3.tag === 1) { + var match$4 = type_format_gen(fmt[1], match$3[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* String */{ + 0: match$2[0], + 1: match$4[0], + length: 2, + tag: 2 + }, + 1: match$4[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 3 : - var match$5 = type_padding(fmt[1], fmtty); - var match$6 = match$5[2]; + var match$5 = type_padding(fmt[0], fmtty); + var match$6 = match$5[1]; if (typeof match$6 === "number") { throw Type_mismatch; } - else if (match$6[0] === 1) { - var match$7 = type_format_gen(fmt[2], match$6[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Caml_string */3, - match$5[1], - match$7[1] - ], - match$7[2] - ]; + else if (match$6.tag === 1) { + var match$7 = type_format_gen(fmt[1], match$6[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Caml_string */{ + 0: match$5[0], + 1: match$7[0], + length: 2, + tag: 3 + }, + 1: match$7[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 4 : - var match$8 = type_padprec(fmt[2], fmt[3], fmtty); - var match$9 = match$8[3]; + var match$8 = type_padprec(fmt[1], fmt[2], fmtty); + var match$9 = match$8[2]; if (typeof match$9 === "number") { throw Type_mismatch; } - else if (match$9[0] === 2) { - var match$10 = type_format_gen(fmt[4], match$9[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Int */4, - fmt[1], - match$8[1], - match$8[2], - match$10[1] - ], - match$10[2] - ]; + else if (match$9.tag === 2) { + var match$10 = type_format_gen(fmt[3], match$9[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Int */{ + 0: fmt[0], + 1: match$8[0], + 2: match$8[1], + 3: match$10[0], + length: 4, + tag: 4 + }, + 1: match$10[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 5 : - var match$11 = type_padprec(fmt[2], fmt[3], fmtty); - var match$12 = match$11[3]; + var match$11 = type_padprec(fmt[1], fmt[2], fmtty); + var match$12 = match$11[2]; if (typeof match$12 === "number") { throw Type_mismatch; } - else if (match$12[0] === 3) { - var match$13 = type_format_gen(fmt[4], match$12[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Int32 */5, - fmt[1], - match$11[1], - match$11[2], - match$13[1] - ], - match$13[2] - ]; + else if (match$12.tag === 3) { + var match$13 = type_format_gen(fmt[3], match$12[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Int32 */{ + 0: fmt[0], + 1: match$11[0], + 2: match$11[1], + 3: match$13[0], + length: 4, + tag: 5 + }, + 1: match$13[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 6 : - var match$14 = type_padprec(fmt[2], fmt[3], fmtty); - var match$15 = match$14[3]; + var match$14 = type_padprec(fmt[1], fmt[2], fmtty); + var match$15 = match$14[2]; if (typeof match$15 === "number") { throw Type_mismatch; } - else if (match$15[0] === 4) { - var match$16 = type_format_gen(fmt[4], match$15[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Nativeint */6, - fmt[1], - match$14[1], - match$14[2], - match$16[1] - ], - match$16[2] - ]; + else if (match$15.tag === 4) { + var match$16 = type_format_gen(fmt[3], match$15[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Nativeint */{ + 0: fmt[0], + 1: match$14[0], + 2: match$14[1], + 3: match$16[0], + length: 4, + tag: 6 + }, + 1: match$16[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 7 : - var match$17 = type_padprec(fmt[2], fmt[3], fmtty); - var match$18 = match$17[3]; + var match$17 = type_padprec(fmt[1], fmt[2], fmtty); + var match$18 = match$17[2]; if (typeof match$18 === "number") { throw Type_mismatch; } - else if (match$18[0] === 5) { - var match$19 = type_format_gen(fmt[4], match$18[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Int64 */7, - fmt[1], - match$17[1], - match$17[2], - match$19[1] - ], - match$19[2] - ]; + else if (match$18.tag === 5) { + var match$19 = type_format_gen(fmt[3], match$18[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Int64 */{ + 0: fmt[0], + 1: match$17[0], + 2: match$17[1], + 3: match$19[0], + length: 4, + tag: 7 + }, + 1: match$19[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 8 : - var match$20 = type_padprec(fmt[2], fmt[3], fmtty); - var match$21 = match$20[3]; + var match$20 = type_padprec(fmt[1], fmt[2], fmtty); + var match$21 = match$20[2]; if (typeof match$21 === "number") { throw Type_mismatch; } - else if (match$21[0] === 6) { - var match$22 = type_format_gen(fmt[4], match$21[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Float */8, - fmt[1], - match$20[1], - match$20[2], - match$22[1] - ], - match$22[2] - ]; + else if (match$21.tag === 6) { + var match$22 = type_format_gen(fmt[3], match$21[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Float */{ + 0: fmt[0], + 1: match$20[0], + 2: match$20[1], + 3: match$22[0], + length: 4, + tag: 8 + }, + 1: match$22[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -2602,79 +2650,91 @@ function type_format_gen(fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 7) { - var match$23 = type_format_gen(fmt[1], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Bool */9, - match$23[1] - ], - match$23[2] - ]; + else if (fmtty.tag === 7) { + var match$23 = type_format_gen(fmt[0], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Bool */{ + 0: match$23[0], + length: 1, + tag: 9 + }, + 1: match$23[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 10 : - var match$24 = type_format_gen(fmt[1], fmtty); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Flush */10, - match$24[1] - ], - match$24[2] - ]; + var match$24 = type_format_gen(fmt[0], fmtty); + return /* Fmt_fmtty_EBB */{ + 0: /* Flush */{ + 0: match$24[0], + length: 1, + tag: 10 + }, + 1: match$24[1], + length: 2, + tag: 0 + }; case 11 : - var match$25 = type_format_gen(fmt[2], fmtty); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* String_literal */11, - fmt[1], - match$25[1] - ], - match$25[2] - ]; + var match$25 = type_format_gen(fmt[1], fmtty); + return /* Fmt_fmtty_EBB */{ + 0: /* String_literal */{ + 0: fmt[0], + 1: match$25[0], + length: 2, + tag: 11 + }, + 1: match$25[1], + length: 2, + tag: 0 + }; case 12 : - var match$26 = type_format_gen(fmt[2], fmtty); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Char_literal */12, - fmt[1], - match$26[1] - ], - match$26[2] - ]; + var match$26 = type_format_gen(fmt[1], fmtty); + return /* Fmt_fmtty_EBB */{ + 0: /* Char_literal */{ + 0: fmt[0], + 1: match$26[0], + length: 2, + tag: 12 + }, + 1: match$26[1], + length: 2, + tag: 0 + }; case 13 : if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 8) { - var sub_fmtty$prime = fmtty[1]; - if (Caml_primitive.caml_notequal([ - /* Fmtty_EBB */0, - fmt[2] - ], [ - /* Fmtty_EBB */0, - sub_fmtty$prime - ])) { + else if (fmtty.tag === 8) { + var sub_fmtty$prime = fmtty[0]; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + 0: fmt[1], + length: 1, + tag: 0 + }, /* Fmtty_EBB */{ + 0: sub_fmtty$prime, + length: 1, + tag: 0 + })) { throw Type_mismatch; } - var match$27 = type_format_gen(fmt[3], fmtty[2]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Format_arg */13, - fmt[1], - sub_fmtty$prime, - match$27[1] - ], - match$27[2] - ]; + var match$27 = type_format_gen(fmt[2], fmtty[1]); + return /* Fmt_fmtty_EBB */{ + 0: /* Format_arg */{ + 0: fmt[0], + 1: sub_fmtty$prime, + 2: match$27[0], + length: 3, + tag: 13 + }, + 1: match$27[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -2684,28 +2744,32 @@ function type_format_gen(fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 9) { - var sub_fmtty1 = fmtty[1]; - if (Caml_primitive.caml_notequal([ - /* Fmtty_EBB */0, - CamlinternalFormatBasics.erase_rel(fmt[2]) - ], [ - /* Fmtty_EBB */0, - CamlinternalFormatBasics.erase_rel(sub_fmtty1) - ])) { + else if (fmtty.tag === 9) { + var sub_fmtty1 = fmtty[0]; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + 0: CamlinternalFormatBasics.erase_rel(fmt[1]), + length: 1, + tag: 0 + }, /* Fmtty_EBB */{ + 0: CamlinternalFormatBasics.erase_rel(sub_fmtty1), + length: 1, + tag: 0 + })) { throw Type_mismatch; } - var match$28 = type_format_gen(fmt[3], CamlinternalFormatBasics.erase_rel(fmtty[3])); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Format_subst */14, - fmt[1], - sub_fmtty1, - match$28[1] - ], - match$28[2] - ]; + var match$28 = type_format_gen(fmt[2], CamlinternalFormatBasics.erase_rel(fmtty[2])); + return /* Fmt_fmtty_EBB */{ + 0: /* Format_subst */{ + 0: fmt[0], + 1: sub_fmtty1, + 2: match$28[0], + length: 3, + tag: 14 + }, + 1: match$28[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -2715,16 +2779,18 @@ function type_format_gen(fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 10) { - var match$29 = type_format_gen(fmt[1], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Alpha */15, - match$29[1] - ], - match$29[2] - ]; + else if (fmtty.tag === 10) { + var match$29 = type_format_gen(fmt[0], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Alpha */{ + 0: match$29[0], + length: 1, + tag: 15 + }, + 1: match$29[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -2734,92 +2800,106 @@ function type_format_gen(fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 11) { - var match$30 = type_format_gen(fmt[1], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Theta */16, - match$30[1] - ], - match$30[2] - ]; + else if (fmtty.tag === 11) { + var match$30 = type_format_gen(fmt[0], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Theta */{ + 0: match$30[0], + length: 1, + tag: 16 + }, + 1: match$30[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 17 : - var match$31 = type_format_gen(fmt[2], fmtty); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Formatting_lit */17, - fmt[1], - match$31[1] - ], - match$31[2] - ]; + var match$31 = type_format_gen(fmt[1], fmtty); + return /* Fmt_fmtty_EBB */{ + 0: /* Formatting_lit */{ + 0: fmt[0], + 1: match$31[0], + length: 2, + tag: 17 + }, + 1: match$31[1], + length: 2, + tag: 0 + }; case 18 : - var formatting_gen = fmt[1]; - var fmt0 = fmt[2]; + var formatting_gen = fmt[0]; + var fmt0 = fmt[1]; var fmtty0 = fmtty; - if (formatting_gen[0]) { - var match$32 = formatting_gen[1]; - var match$33 = type_format_gen(match$32[1], fmtty0); - var match$34 = type_format_gen(fmt0, match$33[2]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Formatting_gen */18, - [ - /* Open_box */1, - [ - /* Format */0, - match$33[1], - match$32[2] - ] - ], - match$34[1] - ], - match$34[2] - ]; + if (formatting_gen.tag) { + var match$32 = formatting_gen[0]; + var match$33 = type_format_gen(match$32[0], fmtty0); + var match$34 = type_format_gen(fmt0, match$33[1]); + return /* Fmt_fmtty_EBB */{ + 0: /* Formatting_gen */{ + 0: /* Open_box */{ + 0: /* Format */{ + 0: match$33[0], + 1: match$32[1], + length: 2, + tag: 0 + }, + length: 1, + tag: 1 + }, + 1: match$34[0], + length: 2, + tag: 18 + }, + 1: match$34[1], + length: 2, + tag: 0 + }; } else { - var match$35 = formatting_gen[1]; - var match$36 = type_format_gen(match$35[1], fmtty0); - var match$37 = type_format_gen(fmt0, match$36[2]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Formatting_gen */18, - [ - /* Open_tag */0, - [ - /* Format */0, - match$36[1], - match$35[2] - ] - ], - match$37[1] - ], - match$37[2] - ]; + var match$35 = formatting_gen[0]; + var match$36 = type_format_gen(match$35[0], fmtty0); + var match$37 = type_format_gen(fmt0, match$36[1]); + return /* Fmt_fmtty_EBB */{ + 0: /* Formatting_gen */{ + 0: /* Open_tag */{ + 0: /* Format */{ + 0: match$36[0], + 1: match$35[1], + length: 2, + tag: 0 + }, + length: 1, + tag: 0 + }, + 1: match$37[0], + length: 2, + tag: 18 + }, + 1: match$37[1], + length: 2, + tag: 0 + }; } case 19 : if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 13) { - var match$38 = type_format_gen(fmt[1], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Reader */19, - match$38[1] - ], - match$38[2] - ]; + else if (fmtty.tag === 13) { + var match$38 = type_format_gen(fmt[0], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Reader */{ + 0: match$38[0], + length: 1, + tag: 19 + }, + 1: match$38[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -2829,18 +2909,20 @@ function type_format_gen(fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 1) { - var match$39 = type_format_gen(fmt[3], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Scan_char_set */20, - fmt[1], - fmt[2], - match$39[1] - ], - match$39[2] - ]; + else if (fmtty.tag === 1) { + var match$39 = type_format_gen(fmt[2], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Scan_char_set */{ + 0: fmt[0], + 1: fmt[1], + 2: match$39[0], + length: 3, + tag: 20 + }, + 1: match$39[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -2850,25 +2932,27 @@ function type_format_gen(fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 2) { - var match$40 = type_format_gen(fmt[2], fmtty[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Scan_get_counter */21, - fmt[1], - match$40[1] - ], - match$40[2] - ]; + else if (fmtty.tag === 2) { + var match$40 = type_format_gen(fmt[1], fmtty[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Scan_get_counter */{ + 0: fmt[0], + 1: match$40[0], + length: 2, + tag: 21 + }, + 1: match$40[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; } break; case 23 : - var ign = fmt[1]; - var fmt$1 = fmt[2]; + var ign = fmt[0]; + var fmt$1 = fmt[1]; var fmtty$1 = fmtty; if (typeof ign === "number") { switch (ign) { @@ -2876,17 +2960,19 @@ function type_format_gen(fmt, fmtty) { if (typeof fmtty$1 === "number") { throw Type_mismatch; } - else if (fmtty$1[0] === 14) { - var match$41 = type_format_gen(fmt$1, fmtty$1[1]); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Ignored_param */23, - /* Ignored_reader */3, - match$41[1] - ], - match$41[2] - ]; + else if (fmtty$1.tag === 14) { + var match$41 = type_format_gen(fmt$1, fmtty$1[0]); + return /* Fmt_fmtty_EBB */{ + 0: /* Ignored_param */{ + 0: /* Ignored_reader */3, + 1: match$41[0], + length: 2, + tag: 23 + }, + 1: match$41[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -2901,29 +2987,33 @@ function type_format_gen(fmt, fmtty) { } } else { - switch (ign[0]) { + switch (ign.tag | 0) { case 7 : - return type_ignored_param_one([ - /* Ignored_format_arg */7, - ign[1], - ign[2] - ], fmt$1, fmtty$1); + return type_ignored_param_one(/* Ignored_format_arg */{ + 0: ign[0], + 1: ign[1], + length: 2, + tag: 7 + }, fmt$1, fmtty$1); case 8 : - var match$42 = type_ignored_format_substitution(ign[2], fmt$1, fmtty$1); - var match$43 = match$42[2]; - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Ignored_param */23, - [ - /* Ignored_format_subst */8, - ign[1], - match$42[1] - ], - match$43[1] - ], - match$43[2] - ]; + var match$42 = type_ignored_format_substitution(ign[1], fmt$1, fmtty$1); + var match$43 = match$42[1]; + return /* Fmt_fmtty_EBB */{ + 0: /* Ignored_param */{ + 0: /* Ignored_format_subst */{ + 0: ign[0], + 1: match$42[0], + length: 2, + tag: 8 + }, + 1: match$43[0], + length: 2, + tag: 23 + }, + 1: match$43[1], + length: 2, + tag: 0 + }; case 0 : case 1 : case 2 : @@ -2947,60 +3037,67 @@ function type_format_gen(fmt, fmtty) { function type_ignored_param_one(ign, fmt, fmtty) { var match = type_format_gen(fmt, fmtty); - return [ - /* Fmt_fmtty_EBB */0, - [ - /* Ignored_param */23, - ign, - match[1] - ], - match[2] - ]; + return /* Fmt_fmtty_EBB */{ + 0: /* Ignored_param */{ + 0: ign, + 1: match[0], + length: 2, + tag: 23 + }, + 1: match[1], + length: 2, + tag: 0 + }; } function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof sub_fmtty === "number") { - return [ - /* Fmtty_fmt_EBB */0, - /* End_of_fmtty */0, - type_format_gen(fmt, fmtty) - ]; + return /* Fmtty_fmt_EBB */{ + 0: /* End_of_fmtty */0, + 1: type_format_gen(fmt, fmtty), + length: 2, + tag: 0 + }; } else { - switch (sub_fmtty[0]) { + switch (sub_fmtty.tag | 0) { case 0 : if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0]) { + else if (fmtty.tag) { throw Type_mismatch; } else { - var match = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Char_ty */0, - match[1] - ], - match[2] - ]; + var match = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Char_ty */{ + 0: match[0], + length: 1, + tag: 0 + }, + 1: match[1], + length: 2, + tag: 0 + }; } break; case 1 : if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 1) { - var match$1 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* String_ty */1, - match$1[1] - ], - match$1[2] - ]; + else if (fmtty.tag === 1) { + var match$1 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* String_ty */{ + 0: match$1[0], + length: 1, + tag: 1 + }, + 1: match$1[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3010,16 +3107,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 2) { - var match$2 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Int_ty */2, - match$2[1] - ], - match$2[2] - ]; + else if (fmtty.tag === 2) { + var match$2 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Int_ty */{ + 0: match$2[0], + length: 1, + tag: 2 + }, + 1: match$2[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3029,16 +3128,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 3) { - var match$3 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Int32_ty */3, - match$3[1] - ], - match$3[2] - ]; + else if (fmtty.tag === 3) { + var match$3 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Int32_ty */{ + 0: match$3[0], + length: 1, + tag: 3 + }, + 1: match$3[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3048,16 +3149,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 4) { - var match$4 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Nativeint_ty */4, - match$4[1] - ], - match$4[2] - ]; + else if (fmtty.tag === 4) { + var match$4 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Nativeint_ty */{ + 0: match$4[0], + length: 1, + tag: 4 + }, + 1: match$4[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3067,16 +3170,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 5) { - var match$5 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Int64_ty */5, - match$5[1] - ], - match$5[2] - ]; + else if (fmtty.tag === 5) { + var match$5 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Int64_ty */{ + 0: match$5[0], + length: 1, + tag: 5 + }, + 1: match$5[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3086,16 +3191,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 6) { - var match$6 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Float_ty */6, - match$6[1] - ], - match$6[2] - ]; + else if (fmtty.tag === 6) { + var match$6 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Float_ty */{ + 0: match$6[0], + length: 1, + tag: 6 + }, + 1: match$6[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3105,16 +3212,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 7) { - var match$7 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Bool_ty */7, - match$7[1] - ], - match$7[2] - ]; + else if (fmtty.tag === 7) { + var match$7 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Bool_ty */{ + 0: match$7[0], + length: 1, + tag: 7 + }, + 1: match$7[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3124,27 +3233,31 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 8) { - var sub2_fmtty$prime = fmtty[1]; - if (Caml_primitive.caml_notequal([ - /* Fmtty_EBB */0, - sub_fmtty[1] - ], [ - /* Fmtty_EBB */0, - sub2_fmtty$prime - ])) { + else if (fmtty.tag === 8) { + var sub2_fmtty$prime = fmtty[0]; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + 0: sub_fmtty[0], + length: 1, + tag: 0 + }, /* Fmtty_EBB */{ + 0: sub2_fmtty$prime, + length: 1, + tag: 0 + })) { throw Type_mismatch; } - var match$8 = type_ignored_format_substitution(sub_fmtty[2], fmt, fmtty[2]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Format_arg_ty */8, - sub2_fmtty$prime, - match$8[1] - ], - match$8[2] - ]; + var match$8 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); + return /* Fmtty_fmt_EBB */{ + 0: /* Format_arg_ty */{ + 0: sub2_fmtty$prime, + 1: match$8[0], + length: 2, + tag: 8 + }, + 1: match$8[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3154,42 +3267,48 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 9) { - var sub2_fmtty$prime$1 = fmtty[2]; - var sub1_fmtty$prime = fmtty[1]; - if (Caml_primitive.caml_notequal([ - /* Fmtty_EBB */0, - CamlinternalFormatBasics.erase_rel(sub_fmtty[1]) - ], [ - /* Fmtty_EBB */0, - CamlinternalFormatBasics.erase_rel(sub1_fmtty$prime) - ])) { + else if (fmtty.tag === 9) { + var sub2_fmtty$prime$1 = fmtty[1]; + var sub1_fmtty$prime = fmtty[0]; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + 0: CamlinternalFormatBasics.erase_rel(sub_fmtty[0]), + length: 1, + tag: 0 + }, /* Fmtty_EBB */{ + 0: CamlinternalFormatBasics.erase_rel(sub1_fmtty$prime), + length: 1, + tag: 0 + })) { throw Type_mismatch; } - if (Caml_primitive.caml_notequal([ - /* Fmtty_EBB */0, - CamlinternalFormatBasics.erase_rel(sub_fmtty[2]) - ], [ - /* Fmtty_EBB */0, - CamlinternalFormatBasics.erase_rel(sub2_fmtty$prime$1) - ])) { + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + 0: CamlinternalFormatBasics.erase_rel(sub_fmtty[1]), + length: 1, + tag: 0 + }, /* Fmtty_EBB */{ + 0: CamlinternalFormatBasics.erase_rel(sub2_fmtty$prime$1), + length: 1, + tag: 0 + })) { throw Type_mismatch; } var sub_fmtty$prime = trans(symm(sub1_fmtty$prime), sub2_fmtty$prime$1); var match$9 = fmtty_rel_det(sub_fmtty$prime); - Caml_curry.app1(match$9[2], /* Refl */0); - Caml_curry.app1(match$9[4], /* Refl */0); - var match$10 = type_ignored_format_substitution(CamlinternalFormatBasics.erase_rel(sub_fmtty[3]), fmt, fmtty[3]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Format_subst_ty */9, - sub1_fmtty$prime, - sub2_fmtty$prime$1, - symm(match$10[1]) - ], - match$10[2] - ]; + Caml_curry.app1(match$9[1], /* Refl */0); + Caml_curry.app1(match$9[3], /* Refl */0); + var match$10 = type_ignored_format_substitution(CamlinternalFormatBasics.erase_rel(sub_fmtty[2]), fmt, fmtty[2]); + return /* Fmtty_fmt_EBB */{ + 0: /* Format_subst_ty */{ + 0: sub1_fmtty$prime, + 1: sub2_fmtty$prime$1, + 2: symm(match$10[0]), + length: 3, + tag: 9 + }, + 1: match$10[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3199,16 +3318,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 10) { - var match$11 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Alpha_ty */10, - match$11[1] - ], - match$11[2] - ]; + else if (fmtty.tag === 10) { + var match$11 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Alpha_ty */{ + 0: match$11[0], + length: 1, + tag: 10 + }, + 1: match$11[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3218,16 +3339,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 11) { - var match$12 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Theta_ty */11, - match$12[1] - ], - match$12[2] - ]; + else if (fmtty.tag === 11) { + var match$12 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Theta_ty */{ + 0: match$12[0], + length: 1, + tag: 11 + }, + 1: match$12[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3239,16 +3362,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 13) { - var match$13 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Reader_ty */13, - match$13[1] - ], - match$13[2] - ]; + else if (fmtty.tag === 13) { + var match$13 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Reader_ty */{ + 0: match$13[0], + length: 1, + tag: 13 + }, + 1: match$13[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3258,16 +3383,18 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { if (typeof fmtty === "number") { throw Type_mismatch; } - else if (fmtty[0] === 14) { - var match$14 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return [ - /* Fmtty_fmt_EBB */0, - [ - /* Ignored_reader_ty */14, - match$14[1] - ], - match$14[2] - ]; + else if (fmtty.tag === 14) { + var match$14 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); + return /* Fmtty_fmt_EBB */{ + 0: /* Ignored_reader_ty */{ + 0: match$14[0], + length: 1, + tag: 14 + }, + 1: match$14[1], + length: 2, + tag: 0 + }; } else { throw Type_mismatch; @@ -3284,10 +3411,10 @@ function recast(fmt, fmtty) { function fix_padding(padty, width, str) { var len = str.length; - var match_001 = Pervasives.abs(width); - var match_002 = width < 0 ? /* Left */0 : padty; - var padty$1 = match_002; - var width$1 = match_001; + var match_000 = Pervasives.abs(width); + var match_001 = width < 0 ? /* Left */0 : padty; + var padty$1 = match_001; + var width$1 = match_000; if (width$1 <= len) { return str; } @@ -3410,11 +3537,9 @@ function fix_int_precision(prec, str) { } function string_to_caml_string(str) { - return $$String.concat($$String.escaped(str), [ - /* :: */0, + return $$String.concat($$String.escaped(str), /* :: */[ '"', - [ - /* :: */0, + /* :: */[ '"', /* [] */0 ] @@ -3457,143 +3582,117 @@ function format_of_aconv(iconv, c) { var seps; switch (iconv) { case 0 : - seps = [ - /* :: */0, + seps = /* :: */[ "%", - [ - /* :: */0, + /* :: */[ "d", /* [] */0 ] ]; break; case 1 : - seps = [ - /* :: */0, + seps = /* :: */[ "%+", - [ - /* :: */0, + /* :: */[ "d", /* [] */0 ] ]; break; case 2 : - seps = [ - /* :: */0, + seps = /* :: */[ "% ", - [ - /* :: */0, + /* :: */[ "d", /* [] */0 ] ]; break; case 3 : - seps = [ - /* :: */0, + seps = /* :: */[ "%", - [ - /* :: */0, + /* :: */[ "i", /* [] */0 ] ]; break; case 4 : - seps = [ - /* :: */0, + seps = /* :: */[ "%+", - [ - /* :: */0, + /* :: */[ "i", /* [] */0 ] ]; break; case 5 : - seps = [ - /* :: */0, + seps = /* :: */[ "% ", - [ - /* :: */0, + /* :: */[ "i", /* [] */0 ] ]; break; case 6 : - seps = [ - /* :: */0, + seps = /* :: */[ "%", - [ - /* :: */0, + /* :: */[ "x", /* [] */0 ] ]; break; case 7 : - seps = [ - /* :: */0, + seps = /* :: */[ "%#", - [ - /* :: */0, + /* :: */[ "x", /* [] */0 ] ]; break; case 8 : - seps = [ - /* :: */0, + seps = /* :: */[ "%", - [ - /* :: */0, + /* :: */[ "X", /* [] */0 ] ]; break; case 9 : - seps = [ - /* :: */0, + seps = /* :: */[ "%#", - [ - /* :: */0, + /* :: */[ "X", /* [] */0 ] ]; break; case 10 : - seps = [ - /* :: */0, + seps = /* :: */[ "%", - [ - /* :: */0, + /* :: */[ "o", /* [] */0 ] ]; break; case 11 : - seps = [ - /* :: */0, + seps = /* :: */[ "%#", - [ - /* :: */0, + /* :: */[ "o", /* [] */0 ] ]; break; case 12 : - seps = [ - /* :: */0, + seps = /* :: */[ "%", - [ - /* :: */0, + /* :: */[ "u", /* [] */0 ] @@ -3611,8 +3710,7 @@ function format_of_fconv(fconv, prec) { else { var prec$1 = Pervasives.abs(prec); var symb = char_of_fconv(fconv); - var buf = [ - /* record */0, + var buf = /* record */[ 0, new Array(16) ]; @@ -3701,11 +3799,9 @@ function convert_float(fconv, prec, x) { } function format_caml_char(c) { - return $$String.concat(Char.escaped(c), [ - /* :: */0, + return $$String.concat(Char.escaped(c), /* :: */[ "'", - [ - /* :: */0, + /* :: */[ "'", /* [] */0 ] @@ -3713,8 +3809,7 @@ function format_caml_char(c) { } function string_of_fmtty(fmtty) { - var buf = [ - /* record */0, + var buf = /* record */[ 0, new Array(16) ]; @@ -3731,65 +3826,68 @@ function make_printf(_k, o, _acc, _fmt) { return Caml_curry.app2(k, o, acc); } else { - switch (fmt[0]) { + switch (fmt.tag | 0) { case 0 : - var rest = fmt[1]; + var rest = fmt[0]; return (function(k,acc,rest){ return function (c) { - var new_acc = [ - /* Acc_data_char */5, - acc, - c - ]; + var new_acc = /* Acc_data_char */{ + 0: acc, + 1: c, + length: 2, + tag: 5 + }; return make_printf(k, o, new_acc, rest); } }(k,acc,rest)); case 1 : - var rest$1 = fmt[1]; + var rest$1 = fmt[0]; return (function(k,acc,rest$1){ return function (c) { - var new_acc_002 = format_caml_char(c); - var new_acc = [ - /* Acc_data_string */4, - acc, - new_acc_002 - ]; + var new_acc_001 = format_caml_char(c); + var new_acc = /* Acc_data_string */{ + 0: acc, + 1: new_acc_001, + length: 2, + tag: 4 + }; return make_printf(k, o, new_acc, rest$1); } }(k,acc,rest$1)); case 2 : - return make_string_padding(k, o, acc, fmt[2], fmt[1], function (str) { + return make_string_padding(k, o, acc, fmt[1], fmt[0], function (str) { return str; }); case 3 : - return make_string_padding(k, o, acc, fmt[2], fmt[1], string_to_caml_string); + return make_string_padding(k, o, acc, fmt[1], fmt[0], string_to_caml_string); case 4 : - return make_int_padding_precision(k, o, acc, fmt[4], fmt[2], fmt[3], convert_int, fmt[1]); + return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_int, fmt[0]); case 5 : - return make_int_padding_precision(k, o, acc, fmt[4], fmt[2], fmt[3], convert_int32, fmt[1]); + return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_int32, fmt[0]); case 6 : - return make_int_padding_precision(k, o, acc, fmt[4], fmt[2], fmt[3], convert_nativeint, fmt[1]); + return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_nativeint, fmt[0]); case 7 : - return make_int_padding_precision(k, o, acc, fmt[4], fmt[2], fmt[3], convert_int64, fmt[1]); + return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_int64, fmt[0]); case 8 : var k$1 = k; var o$1 = o; var acc$1 = acc; - var fmt$1 = fmt[4]; - var pad = fmt[2]; - var prec = fmt[3]; - var fconv = fmt[1]; + var fmt$1 = fmt[3]; + var pad = fmt[1]; + var prec = fmt[2]; + var fconv = fmt[0]; if (typeof pad === "number") { if (typeof prec === "number") { if (prec !== 0) { return (function(k$1,o$1,acc$1,fmt$1,fconv){ return function (p, x) { var str = convert_float(fconv, p, x); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv)); } @@ -3797,41 +3895,44 @@ function make_printf(_k, o, _acc, _fmt) { return (function(k$1,o$1,acc$1,fmt$1,fconv){ return function (x) { var str = convert_float(fconv, default_float_precision, x); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv)); } } else { - var p = prec[1]; + var p = prec[0]; return (function(k$1,o$1,acc$1,fmt$1,fconv,p){ return function (x) { var str = convert_float(fconv, p, x); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv,p)); } } - else if (pad[0]) { - var padty = pad[1]; + else if (pad.tag) { + var padty = pad[0]; if (typeof prec === "number") { if (prec !== 0) { return (function(k$1,o$1,acc$1,fmt$1,fconv,padty){ return function (w, p, x) { var str = fix_padding(padty, w, convert_float(fconv, p, x)); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv,padty)); } @@ -3840,42 +3941,45 @@ function make_printf(_k, o, _acc, _fmt) { return function (w, x) { var str = convert_float(fconv, default_float_precision, x); var str$prime = fix_padding(padty, w, str); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str$prime - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str$prime, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv,padty)); } } else { - var p$1 = prec[1]; + var p$1 = prec[0]; return (function(k$1,o$1,acc$1,fmt$1,fconv,padty,p$1){ return function (w, x) { var str = fix_padding(padty, w, convert_float(fconv, p$1, x)); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv,padty,p$1)); } } else { - var w = pad[2]; - var padty$1 = pad[1]; + var w = pad[1]; + var padty$1 = pad[0]; if (typeof prec === "number") { if (prec !== 0) { return (function(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w){ return function (p, x) { var str = fix_padding(padty$1, w, convert_float(fconv, p, x)); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w)); } @@ -3884,152 +3988,166 @@ function make_printf(_k, o, _acc, _fmt) { return function (x) { var str = convert_float(fconv, default_float_precision, x); var str$prime = fix_padding(padty$1, w, str); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str$prime - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str$prime, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w)); } } else { - var p$2 = prec[1]; + var p$2 = prec[0]; return (function(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w,p$2){ return function (x) { var str = fix_padding(padty$1, w, convert_float(fconv, p$2, x)); - return make_printf(k$1, o$1, [ - /* Acc_data_string */4, - acc$1, - str - ], fmt$1); + return make_printf(k$1, o$1, /* Acc_data_string */{ + 0: acc$1, + 1: str, + length: 2, + tag: 4 + }, fmt$1); } }(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w,p$2)); } } case 9 : - var rest$2 = fmt[1]; + var rest$2 = fmt[0]; return (function(k,acc,rest$2){ return function (b) { - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - b ? "true" : "false" - ], rest$2); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: b ? "true" : "false", + length: 2, + tag: 4 + }, rest$2); } }(k,acc,rest$2)); case 10 : - _fmt = fmt[1]; - _acc = [ - /* Acc_flush */7, - acc - ]; + _fmt = fmt[0]; + _acc = /* Acc_flush */{ + 0: acc, + length: 1, + tag: 7 + }; continue ; case 11 : - _fmt = fmt[2]; - _acc = [ - /* Acc_string_literal */2, - acc, - fmt[1] - ]; + _fmt = fmt[1]; + _acc = /* Acc_string_literal */{ + 0: acc, + 1: fmt[0], + length: 2, + tag: 2 + }; continue ; case 12 : - _fmt = fmt[2]; - _acc = [ - /* Acc_char_literal */3, - acc, - fmt[1] - ]; + _fmt = fmt[1]; + _acc = /* Acc_char_literal */{ + 0: acc, + 1: fmt[0], + length: 2, + tag: 3 + }; continue ; case 13 : - var rest$3 = fmt[3]; - var ty = string_of_fmtty(fmt[2]); + var rest$3 = fmt[2]; + var ty = string_of_fmtty(fmt[1]); return (function(k,acc,rest$3,ty){ return function () { - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - ty - ], rest$3); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: ty, + length: 2, + tag: 4 + }, rest$3); } }(k,acc,rest$3,ty)); case 14 : - var rest$4 = fmt[3]; - var fmtty = fmt[2]; + var rest$4 = fmt[2]; + var fmtty = fmt[1]; return (function(k,acc,fmtty,rest$4){ return function (param) { - return make_printf(k, o, acc, CamlinternalFormatBasics.concat_fmt(recast(param[1], fmtty), rest$4)); + return make_printf(k, o, acc, CamlinternalFormatBasics.concat_fmt(recast(param[0], fmtty), rest$4)); } }(k,acc,fmtty,rest$4)); case 15 : - var rest$5 = fmt[1]; + var rest$5 = fmt[0]; return (function(k,acc,rest$5){ return function (f, x) { - return make_printf(k, o, [ - /* Acc_delay */6, - acc, - function (o) { + return make_printf(k, o, /* Acc_delay */{ + 0: acc, + 1: function (o) { return Caml_curry.app2(f, o, x); - } - ], rest$5); + }, + length: 2, + tag: 6 + }, rest$5); } }(k,acc,rest$5)); case 16 : - var rest$6 = fmt[1]; + var rest$6 = fmt[0]; return (function(k,acc,rest$6){ return function (f) { - return make_printf(k, o, [ - /* Acc_delay */6, - acc, - f - ], rest$6); + return make_printf(k, o, /* Acc_delay */{ + 0: acc, + 1: f, + length: 2, + tag: 6 + }, rest$6); } }(k,acc,rest$6)); case 17 : - _fmt = fmt[2]; - _acc = [ - /* Acc_formatting_lit */0, - acc, - fmt[1] - ]; + _fmt = fmt[1]; + _acc = /* Acc_formatting_lit */{ + 0: acc, + 1: fmt[0], + length: 2, + tag: 0 + }; continue ; case 18 : - var match = fmt[1]; - if (match[0]) { - var rest$7 = fmt[2]; + var match = fmt[0]; + if (match.tag) { + var rest$7 = fmt[1]; var k$prime = (function(k,acc,rest$7){ return function (koc, kacc) { - return make_printf(k, koc, [ - /* Acc_formatting_gen */1, - acc, - [ - /* Acc_open_box */1, - kacc - ] - ], rest$7); + return make_printf(k, koc, /* Acc_formatting_gen */{ + 0: acc, + 1: /* Acc_open_box */{ + 0: kacc, + length: 1, + tag: 1 + }, + length: 2, + tag: 1 + }, rest$7); } }(k,acc,rest$7)); - _fmt = match[1][1]; + _fmt = match[0][0]; _acc = /* End_of_acc */0; _k = k$prime; continue ; } else { - var rest$8 = fmt[2]; + var rest$8 = fmt[1]; var k$prime$1 = (function(k,acc,rest$8){ return function (koc, kacc) { - return make_printf(k, koc, [ - /* Acc_formatting_gen */1, - acc, - [ - /* Acc_open_tag */0, - kacc - ] - ], rest$8); + return make_printf(k, koc, /* Acc_formatting_gen */{ + 0: acc, + 1: /* Acc_open_tag */{ + 0: kacc, + length: 1, + tag: 0 + }, + length: 2, + tag: 1 + }, rest$8); } }(k,acc,rest$8)); - _fmt = match[1][1]; + _fmt = match[0][0]; _acc = /* End_of_acc */0; _k = k$prime$1; continue ; @@ -4038,49 +4156,50 @@ function make_printf(_k, o, _acc, _fmt) { break; case 19 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 1449, 4 ] ]; case 20 : - var rest$9 = fmt[3]; - var new_acc = [ - /* Acc_invalid_arg */8, - acc, - "Printf: bad conversion %[" - ]; + var rest$9 = fmt[2]; + var new_acc = /* Acc_invalid_arg */{ + 0: acc, + 1: "Printf: bad conversion %[", + length: 2, + tag: 8 + }; return (function(k,rest$9,new_acc){ return function () { return make_printf(k, o, new_acc, rest$9); } }(k,rest$9,new_acc)); case 21 : - var rest$10 = fmt[2]; + var rest$10 = fmt[1]; return (function(k,acc,rest$10){ return function (n) { - var new_acc_002 = Caml_format.caml_format_int("%u", n); - var new_acc = [ - /* Acc_data_string */4, - acc, - new_acc_002 - ]; + var new_acc_001 = Caml_format.caml_format_int("%u", n); + var new_acc = /* Acc_data_string */{ + 0: acc, + 1: new_acc_001, + length: 2, + tag: 4 + }; return make_printf(k, o, new_acc, rest$10); } }(k,acc,rest$10)); case 22 : - var rest$11 = fmt[1]; + var rest$11 = fmt[0]; return (function(k,acc,rest$11){ return function (c) { - var new_acc = [ - /* Acc_data_char */5, - acc, - c - ]; + var new_acc = /* Acc_data_char */{ + 0: acc, + 1: c, + length: 2, + tag: 5 + }; return make_printf(k, o, new_acc, rest$11); } }(k,acc,rest$11)); @@ -4088,16 +4207,14 @@ function make_printf(_k, o, _acc, _fmt) { var k$2 = k; var o$2 = o; var acc$2 = acc; - var ign = fmt[1]; - var fmt$2 = fmt[2]; + var ign = fmt[0]; + var fmt$2 = fmt[1]; if (typeof ign === "number") { switch (ign) { case 3 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 1517, 39 @@ -4112,9 +4229,9 @@ function make_printf(_k, o, _acc, _fmt) { } } else { - switch (ign[0]) { + switch (ign.tag | 0) { case 8 : - return make_from_fmtty(k$2, o$2, acc$2, ign[2], fmt$2); + return make_from_fmtty(k$2, o$2, acc$2, ign[1], fmt$2); case 0 : case 1 : case 2 : @@ -4130,7 +4247,7 @@ function make_printf(_k, o, _acc, _fmt) { } } case 24 : - return make_custom(k, o, acc, fmt[3], fmt[1], Caml_curry.app1(fmt[2], /* () */0)); + return make_custom(k, o, acc, fmt[2], fmt[0], Caml_curry.app1(fmt[1], /* () */0)); } } @@ -4142,79 +4259,77 @@ function make_from_fmtty(k, o, acc, fmtty, fmt) { return make_invalid_arg(k, o, acc, fmt); } else { - switch (fmtty[0]) { + switch (fmtty.tag | 0) { case 0 : - var rest = fmtty[1]; + var rest = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest, fmt); }; case 1 : - var rest$1 = fmtty[1]; + var rest$1 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$1, fmt); }; case 2 : - var rest$2 = fmtty[1]; + var rest$2 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$2, fmt); }; case 3 : - var rest$3 = fmtty[1]; + var rest$3 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$3, fmt); }; case 4 : - var rest$4 = fmtty[1]; + var rest$4 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$4, fmt); }; case 5 : - var rest$5 = fmtty[1]; + var rest$5 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$5, fmt); }; case 6 : - var rest$6 = fmtty[1]; + var rest$6 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$6, fmt); }; case 7 : - var rest$7 = fmtty[1]; + var rest$7 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$7, fmt); }; case 8 : - var rest$8 = fmtty[2]; + var rest$8 = fmtty[1]; return function () { return make_from_fmtty(k, o, acc, rest$8, fmt); }; case 9 : - var rest$9 = fmtty[3]; - var ty = trans(symm(fmtty[1]), fmtty[2]); + var rest$9 = fmtty[2]; + var ty = trans(symm(fmtty[0]), fmtty[1]); return function () { return make_from_fmtty(k, o, acc, CamlinternalFormatBasics.concat_fmtty(ty, rest$9), fmt); }; case 10 : - var rest$10 = fmtty[1]; + var rest$10 = fmtty[0]; return function (_, _$1) { return make_from_fmtty(k, o, acc, rest$10, fmt); }; case 11 : - var rest$11 = fmtty[1]; + var rest$11 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$11, fmt); }; case 12 : - var rest$12 = fmtty[1]; + var rest$12 = fmtty[0]; return function () { return make_from_fmtty(k, o, acc, rest$12, fmt); }; case 13 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 1540, 31 @@ -4222,10 +4337,8 @@ function make_from_fmtty(k, o, acc, fmtty, fmt) { ]; case 14 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 1541, 31 @@ -4237,47 +4350,51 @@ function make_from_fmtty(k, o, acc, fmtty, fmt) { } function make_invalid_arg(k, o, acc, fmt) { - return make_printf(k, o, [ - /* Acc_invalid_arg */8, - acc, - "Printf: bad conversion %_" - ], fmt); + return make_printf(k, o, /* Acc_invalid_arg */{ + 0: acc, + 1: "Printf: bad conversion %_", + length: 2, + tag: 8 + }, fmt); } function make_string_padding(k, o, acc, fmt, pad, trans) { if (typeof pad === "number") { return function (x) { - var new_acc_002 = Caml_curry.app1(trans, x); - var new_acc = [ - /* Acc_data_string */4, - acc, - new_acc_002 - ]; + var new_acc_001 = Caml_curry.app1(trans, x); + var new_acc = /* Acc_data_string */{ + 0: acc, + 1: new_acc_001, + length: 2, + tag: 4 + }; return make_printf(k, o, new_acc, fmt); }; } - else if (pad[0]) { - var padty = pad[1]; + else if (pad.tag) { + var padty = pad[0]; return function (w, x) { - var new_acc_002 = fix_padding(padty, w, Caml_curry.app1(trans, x)); - var new_acc = [ - /* Acc_data_string */4, - acc, - new_acc_002 - ]; + var new_acc_001 = fix_padding(padty, w, Caml_curry.app1(trans, x)); + var new_acc = /* Acc_data_string */{ + 0: acc, + 1: new_acc_001, + length: 2, + tag: 4 + }; return make_printf(k, o, new_acc, fmt); }; } else { - var width = pad[2]; - var padty$1 = pad[1]; + var width = pad[1]; + var padty$1 = pad[0]; return function (x) { - var new_acc_002 = fix_padding(padty$1, width, Caml_curry.app1(trans, x)); - var new_acc = [ - /* Acc_data_string */4, - acc, - new_acc_002 - ]; + var new_acc_001 = fix_padding(padty$1, width, Caml_curry.app1(trans, x)); + var new_acc = /* Acc_data_string */{ + 0: acc, + 1: new_acc_001, + length: 2, + tag: 4 + }; return make_printf(k, o, new_acc, fmt); }; } @@ -4289,106 +4406,115 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { if (prec !== 0) { return function (p, x) { var str = fix_int_precision(p, Caml_curry.app2(trans, iconv, x)); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } else { return function (x) { var str = Caml_curry.app2(trans, iconv, x); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } } else { - var p = prec[1]; + var p = prec[0]; return function (x) { var str = fix_int_precision(p, Caml_curry.app2(trans, iconv, x)); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } } - else if (pad[0]) { - var padty = pad[1]; + else if (pad.tag) { + var padty = pad[0]; if (typeof prec === "number") { if (prec !== 0) { return function (w, p, x) { var str = fix_padding(padty, w, fix_int_precision(p, Caml_curry.app2(trans, iconv, x))); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } else { return function (w, x) { var str = fix_padding(padty, w, Caml_curry.app2(trans, iconv, x)); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } } else { - var p$1 = prec[1]; + var p$1 = prec[0]; return function (w, x) { var str = fix_padding(padty, w, fix_int_precision(p$1, Caml_curry.app2(trans, iconv, x))); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } } else { - var w = pad[2]; - var padty$1 = pad[1]; + var w = pad[1]; + var padty$1 = pad[0]; if (typeof prec === "number") { if (prec !== 0) { return function (p, x) { var str = fix_padding(padty$1, w, fix_int_precision(p, Caml_curry.app2(trans, iconv, x))); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } else { return function (x) { var str = fix_padding(padty$1, w, Caml_curry.app2(trans, iconv, x)); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } } else { - var p$2 = prec[1]; + var p$2 = prec[0]; return function (x) { var str = fix_padding(padty$1, w, fix_int_precision(p$2, Caml_curry.app2(trans, iconv, x))); - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - str - ], fmt); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: str, + length: 2, + tag: 4 + }, fmt); }; } } @@ -4396,17 +4522,18 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { function make_custom(k, o, acc, rest, arity, f) { if (arity) { - var arity$1 = arity[1]; + var arity$1 = arity[0]; return function (x) { return make_custom(k, o, acc, rest, arity$1, Caml_curry.app1(f, x)); }; } else { - return make_printf(k, o, [ - /* Acc_data_string */4, - acc, - f - ], rest); + return make_printf(k, o, /* Acc_data_string */{ + 0: acc, + 1: f, + length: 2, + tag: 4 + }, rest); } } @@ -4418,24 +4545,24 @@ function output_acc(o, _acc) { return /* () */0; } else { - switch (acc[0]) { + switch (acc.tag | 0) { case 0 : - var s = string_of_formatting_lit(acc[2]); - output_acc(o, acc[1]); + var s = string_of_formatting_lit(acc[1]); + output_acc(o, acc[0]); return Pervasives.output_string(o, s); case 1 : - var match = acc[2]; - var p = acc[1]; + var match = acc[1]; + var p = acc[0]; output_acc(o, p); - if (match[0]) { + if (match.tag) { Pervasives.output_string(o, "@["); - _acc = match[1]; + _acc = match[0]; continue ; } else { Pervasives.output_string(o, "@{"); - _acc = match[1]; + _acc = match[0]; continue ; } @@ -4449,28 +4576,27 @@ function output_acc(o, _acc) { exit = 2; break; case 6 : - output_acc(o, acc[1]); - return Caml_curry.app1(acc[2], o); + output_acc(o, acc[0]); + return Caml_curry.app1(acc[1], o); case 7 : - output_acc(o, acc[1]); + output_acc(o, acc[0]); return Caml_io.caml_ml_flush(o); case 8 : - output_acc(o, acc[1]); + output_acc(o, acc[0]); throw [ - 0, Caml_builtin_exceptions.Invalid_argument, - acc[2] + acc[1] ]; } } switch (exit) { case 1 : - output_acc(o, acc[1]); - return Pervasives.output_string(o, acc[2]); + output_acc(o, acc[0]); + return Pervasives.output_string(o, acc[1]); case 2 : - output_acc(o, acc[1]); - return Caml_io.caml_ml_output_char(o, acc[2]); + output_acc(o, acc[0]); + return Caml_io.caml_ml_output_char(o, acc[1]); } }; @@ -4484,24 +4610,24 @@ function bufput_acc(b, _acc) { return /* () */0; } else { - switch (acc[0]) { + switch (acc.tag | 0) { case 0 : - var s = string_of_formatting_lit(acc[2]); - bufput_acc(b, acc[1]); + var s = string_of_formatting_lit(acc[1]); + bufput_acc(b, acc[0]); return Buffer.add_string(b, s); case 1 : - var match = acc[2]; - var p = acc[1]; + var match = acc[1]; + var p = acc[0]; bufput_acc(b, p); - if (match[0]) { + if (match.tag) { Buffer.add_string(b, "@["); - _acc = match[1]; + _acc = match[0]; continue ; } else { Buffer.add_string(b, "@{"); - _acc = match[1]; + _acc = match[0]; continue ; } @@ -4515,28 +4641,27 @@ function bufput_acc(b, _acc) { exit = 2; break; case 6 : - bufput_acc(b, acc[1]); - return Caml_curry.app1(acc[2], b); + bufput_acc(b, acc[0]); + return Caml_curry.app1(acc[1], b); case 7 : - _acc = acc[1]; + _acc = acc[0]; continue ; case 8 : - bufput_acc(b, acc[1]); + bufput_acc(b, acc[0]); throw [ - 0, Caml_builtin_exceptions.Invalid_argument, - acc[2] + acc[1] ]; } } switch (exit) { case 1 : - bufput_acc(b, acc[1]); - return Buffer.add_string(b, acc[2]); + bufput_acc(b, acc[0]); + return Buffer.add_string(b, acc[1]); case 2 : - bufput_acc(b, acc[1]); - return Buffer.add_char(b, acc[2]); + bufput_acc(b, acc[0]); + return Buffer.add_char(b, acc[1]); } }; @@ -4550,24 +4675,24 @@ function strput_acc(b, _acc) { return /* () */0; } else { - switch (acc[0]) { + switch (acc.tag | 0) { case 0 : - var s = string_of_formatting_lit(acc[2]); - strput_acc(b, acc[1]); + var s = string_of_formatting_lit(acc[1]); + strput_acc(b, acc[0]); return Buffer.add_string(b, s); case 1 : - var match = acc[2]; - var p = acc[1]; + var match = acc[1]; + var p = acc[0]; strput_acc(b, p); - if (match[0]) { + if (match.tag) { Buffer.add_string(b, "@["); - _acc = match[1]; + _acc = match[0]; continue ; } else { Buffer.add_string(b, "@{"); - _acc = match[1]; + _acc = match[0]; continue ; } @@ -4581,28 +4706,27 @@ function strput_acc(b, _acc) { exit = 2; break; case 6 : - strput_acc(b, acc[1]); - return Buffer.add_string(b, Caml_curry.app1(acc[2], /* () */0)); + strput_acc(b, acc[0]); + return Buffer.add_string(b, Caml_curry.app1(acc[1], /* () */0)); case 7 : - _acc = acc[1]; + _acc = acc[0]; continue ; case 8 : - strput_acc(b, acc[1]); + strput_acc(b, acc[0]); throw [ - 0, Caml_builtin_exceptions.Invalid_argument, - acc[2] + acc[1] ]; } } switch (exit) { case 1 : - strput_acc(b, acc[1]); - return Buffer.add_string(b, acc[2]); + strput_acc(b, acc[0]); + return Buffer.add_string(b, acc[1]); case 2 : - strput_acc(b, acc[1]); - return Buffer.add_char(b, acc[2]); + strput_acc(b, acc[0]); + return Buffer.add_char(b, acc[1]); } }; @@ -4614,18 +4738,16 @@ function failwith_message(param) { strput_acc(buf, acc); var s = Buffer.contents(buf); throw [ - 0, Caml_builtin_exceptions.Failure, s ]; }; - return make_printf(k, /* () */0, /* End_of_acc */0, param[1]); + return make_printf(k, /* () */0, /* End_of_acc */0, param[0]); } function open_box_of_string(str) { if (str === "") { - return [ - /* tuple */0, + return /* tuple */[ 0, /* Pp_box */4 ]; @@ -4633,19 +4755,22 @@ function open_box_of_string(str) { else { var len = str.length; var invalid_box = function () { - return Caml_curry.app1(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid box description ", - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "invalid box description %S" - ]), str); + return Caml_curry.app1(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid box description ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid box description %S", + length: 2, + tag: 0 + }), str); }; var parse_spaces = function (_i) { while(true) { @@ -4735,7 +4860,7 @@ function open_box_of_string(str) { indent = Caml_format.caml_int_of_string($$String.sub(str, nstart, nend - nstart)); } catch (exn){ - if (exn[1] === Caml_builtin_exceptions.Failure) { + if (exn[0] === Caml_builtin_exceptions.Failure) { indent = invalid_box(/* () */0); } else { @@ -4768,8 +4893,7 @@ function open_box_of_string(str) { default: box_type = invalid_box(/* () */0); } - return [ - /* tuple */0, + return /* tuple */[ indent, box_type ]; @@ -4778,215 +4902,254 @@ function open_box_of_string(str) { function make_padding_fmt_ebb(pad, fmt) { if (typeof pad === "number") { - return [ - /* Padding_fmt_EBB */0, - /* No_padding */0, - fmt - ]; + return /* Padding_fmt_EBB */{ + 0: /* No_padding */0, + 1: fmt, + length: 2, + tag: 0 + }; } - else if (pad[0]) { - return [ - /* Padding_fmt_EBB */0, - [ - /* Arg_padding */1, - pad[1] - ], - fmt - ]; + else if (pad.tag) { + return /* Padding_fmt_EBB */{ + 0: /* Arg_padding */{ + 0: pad[0], + length: 1, + tag: 1 + }, + 1: fmt, + length: 2, + tag: 0 + }; } else { - return [ - /* Padding_fmt_EBB */0, - [ - /* Lit_padding */0, - pad[1], - pad[2] - ], - fmt - ]; + return /* Padding_fmt_EBB */{ + 0: /* Lit_padding */{ + 0: pad[0], + 1: pad[1], + length: 2, + tag: 0 + }, + 1: fmt, + length: 2, + tag: 0 + }; } } function make_precision_fmt_ebb(prec, fmt) { if (typeof prec === "number") { if (prec !== 0) { - return [ - /* Precision_fmt_EBB */0, - /* Arg_precision */1, - fmt - ]; + return /* Precision_fmt_EBB */{ + 0: /* Arg_precision */1, + 1: fmt, + length: 2, + tag: 0 + }; } else { - return [ - /* Precision_fmt_EBB */0, - /* No_precision */0, - fmt - ]; + return /* Precision_fmt_EBB */{ + 0: /* No_precision */0, + 1: fmt, + length: 2, + tag: 0 + }; } } else { - return [ - /* Precision_fmt_EBB */0, - [ - /* Lit_precision */0, - prec[1] - ], - fmt - ]; + return /* Precision_fmt_EBB */{ + 0: /* Lit_precision */{ + 0: prec[0], + length: 1, + tag: 0 + }, + 1: fmt, + length: 2, + tag: 0 + }; } } function make_padprec_fmt_ebb(pad, prec, fmt) { var match = make_precision_fmt_ebb(prec, fmt); - var fmt$prime = match[2]; - var prec$1 = match[1]; + var fmt$prime = match[1]; + var prec$1 = match[0]; if (typeof pad === "number") { - return [ - /* Padprec_fmt_EBB */0, - /* No_padding */0, - prec$1, - fmt$prime - ]; + return /* Padprec_fmt_EBB */{ + 0: /* No_padding */0, + 1: prec$1, + 2: fmt$prime, + length: 3, + tag: 0 + }; } - else if (pad[0]) { - return [ - /* Padprec_fmt_EBB */0, - [ - /* Arg_padding */1, - pad[1] - ], - prec$1, - fmt$prime - ]; + else if (pad.tag) { + return /* Padprec_fmt_EBB */{ + 0: /* Arg_padding */{ + 0: pad[0], + length: 1, + tag: 1 + }, + 1: prec$1, + 2: fmt$prime, + length: 3, + tag: 0 + }; } else { - return [ - /* Padprec_fmt_EBB */0, - [ - /* Lit_padding */0, - pad[1], - pad[2] - ], - prec$1, - fmt$prime - ]; + return /* Padprec_fmt_EBB */{ + 0: /* Lit_padding */{ + 0: pad[0], + 1: pad[1], + length: 2, + tag: 0 + }, + 1: prec$1, + 2: fmt$prime, + length: 3, + tag: 0 + }; } } function fmt_ebb_of_string(legacy_behavior, str) { - var legacy_behavior$1 = legacy_behavior ? legacy_behavior[1] : /* true */1; + var legacy_behavior$1 = legacy_behavior ? legacy_behavior[0] : /* true */1; var invalid_format_message = function (str_ind, msg) { - return Caml_curry.app3(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": at character number ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", ", - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ] - ] - ] - ], - "invalid format %S: at character number %d, %s" - ]), str, str_ind, msg); + return Caml_curry.app3(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": at character number ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: at character number %d, %s", + length: 2, + tag: 0 + }), str, str_ind, msg); }; var invalid_format_without = function (str_ind, c, s) { - return Caml_curry.app4(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": at character number ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", '", - [ - /* Char */0, - [ - /* String_literal */11, - "' without ", - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ], - "invalid format %S: at character number %d, '%c' without %s" - ]), str, str_ind, c, s); + return Caml_curry.app4(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": at character number ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", '", + 1: /* Char */{ + 0: /* String_literal */{ + 0: "' without ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 1, + tag: 0 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: at character number %d, '%c' without %s", + length: 2, + tag: 0 + }), str, str_ind, c, s); }; var expected_character = function (str_ind, expected, read) { - return Caml_curry.app4(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": at character number ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", ", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - " expected, read ", - [ - /* Caml_char */1, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ], - "invalid format %S: at character number %d, %s expected, read %C" - ]), str, str_ind, expected, read); + return Caml_curry.app4(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": at character number ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " expected, read ", + 1: /* Caml_char */{ + 0: /* End_of_format */0, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: at character number %d, %s expected, read %C", + length: 2, + tag: 0 + }), str, str_ind, expected, read); }; var parse_literal = function (lit_start, _str_ind, end_ind) { while(true) { @@ -5004,12 +5167,12 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else { var match$1 = parse_after_at(str_ind + 1, end_ind); - return add_literal(lit_start, str_ind, match$1[1]); + return add_literal(lit_start, str_ind, match$1[0]); } } else { var match$2 = parse_format(str_ind, end_ind); - return add_literal(lit_start, str_ind, match$2[1]); + return add_literal(lit_start, str_ind, match$2[0]); } } }; @@ -5030,60 +5193,52 @@ function fmt_ebb_of_string(legacy_behavior, str) { } }; var parse_flags = function (pct_ind, str_ind, end_ind, ign) { - var zero = [ - 0, - /* false */0 - ]; - var minus = [ - 0, - /* false */0 - ]; - var plus = [ - 0, - /* false */0 - ]; - var space = [ - 0, - /* false */0 - ]; - var sharp = [ - 0, - /* false */0 - ]; + var zero = [/* false */0]; + var minus = [/* false */0]; + var plus = [/* false */0]; + var space = [/* false */0]; + var sharp = [/* false */0]; var set_flag = function (str_ind, flag) { - if (flag[1] && !legacy_behavior$1) { - Caml_curry.app3(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": at character number ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", duplicate flag ", - [ - /* Caml_char */1, - /* End_of_format */0 - ] - ] - ] - ] - ] - ], - "invalid format %S: at character number %d, duplicate flag %C" - ]), str, str_ind, str.charCodeAt(str_ind)); + if (flag[0] && !legacy_behavior$1) { + Caml_curry.app3(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": at character number ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", duplicate flag ", + 1: /* Caml_char */{ + 0: /* End_of_format */0, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: at character number %d, duplicate flag %C", + length: 2, + tag: 0 + }), str, str_ind, str.charCodeAt(str_ind)); } - flag[1] = /* true */1; + flag[0] = /* true */1; return /* () */0; }; var _str_ind = str_ind; @@ -5141,11 +5296,11 @@ function fmt_ebb_of_string(legacy_behavior, str) { var pct_ind$1 = pct_ind; var str_ind$2 = str_ind$1; var end_ind$1 = end_ind; - var zero$1 = zero[1]; - var minus$1 = minus[1]; - var plus$1 = plus[1]; - var sharp$1 = sharp[1]; - var space$1 = space[1]; + var zero$1 = zero[0]; + var minus$1 = minus[0]; + var plus$1 = plus[0]; + var sharp$1 = sharp[0]; + var space$1 = space[0]; var ign$1 = ign; if (str_ind$2 === end_ind$1) { invalid_format_message(end_ind$1, "unexpected end of format"); @@ -5165,21 +5320,23 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else { var match$2 = parse_positive(str_ind$2, end_ind$1, 0); - return parse_after_padding(pct_ind$1, match$2[1], end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, [ - /* Lit_padding */0, - padty, - match$2[2] - ]); + return parse_after_padding(pct_ind$1, match$2[0], end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, /* Lit_padding */{ + 0: padty, + 1: match$2[1], + length: 2, + tag: 0 + }); } } else if (match$1 !== 42) { exit$1 = 1; } else { - return parse_after_padding(pct_ind$1, str_ind$2 + 1, end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, [ - /* Arg_padding */1, - padty - ]); + return parse_after_padding(pct_ind$1, str_ind$2 + 1, end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, /* Arg_padding */{ + 0: padty, + length: 1, + tag: 1 + }); } if (exit$1 === 1) { switch (padty) { @@ -5191,11 +5348,12 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 1 : return parse_after_padding(pct_ind$1, str_ind$2, end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, /* No_padding */0); case 2 : - return parse_after_padding(pct_ind$1, str_ind$2, end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, [ - /* Lit_padding */0, - /* Right */1, - 0 - ]); + return parse_after_padding(pct_ind$1, str_ind$2, end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, /* Lit_padding */{ + 0: /* Right */1, + 1: 0, + length: 2, + tag: 0 + }); } } @@ -5227,10 +5385,11 @@ function fmt_ebb_of_string(legacy_behavior, str) { } var parse_literal = function (minus, str_ind) { var match = parse_positive(str_ind, end_ind$1, 0); - return parse_after_precision(pct_ind$1, match[1], end_ind$1, minus, plus$1, sharp$1, space$1, ign$1, pad$1, [ - /* Lit_precision */0, - match[2] - ]); + return parse_after_precision(pct_ind$1, match[0], end_ind$1, minus, plus$1, sharp$1, space$1, ign$1, pad$1, /* Lit_precision */{ + 0: match[1], + length: 1, + tag: 0 + }); }; var symb$1 = str.charCodeAt(str_ind$1); var exit = 0; @@ -5272,10 +5431,11 @@ function fmt_ebb_of_string(legacy_behavior, str) { break; case 2 : if (legacy_behavior$1) { - return parse_after_precision(pct_ind$1, str_ind$1, end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, pad$1, [ - /* Lit_precision */0, - 0 - ]); + return parse_after_precision(pct_ind$1, str_ind$1, end_ind$1, minus$1, plus$1, sharp$1, space$1, ign$1, pad$1, /* Lit_precision */{ + 0: 0, + length: 1, + tag: 0 + }); } else { return invalid_format_without(str_ind$1 - 1, /* "." */46, "precision"); @@ -5307,31 +5467,35 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (exit === 1) { if (minus !== 0) { if (typeof prec === "number") { - return parse_conv([ - /* Arg_padding */1, - /* Left */0 - ]); + return parse_conv(/* Arg_padding */{ + 0: /* Left */0, + length: 1, + tag: 1 + }); } else { - return parse_conv([ - /* Lit_padding */0, - /* Left */0, - prec[1] - ]); + return parse_conv(/* Lit_padding */{ + 0: /* Left */0, + 1: prec[0], + length: 2, + tag: 0 + }); } } else if (typeof prec === "number") { - return parse_conv([ - /* Arg_padding */1, - /* Right */1 - ]); + return parse_conv(/* Arg_padding */{ + 0: /* Right */1, + length: 1, + tag: 1 + }); } else { - return parse_conv([ - /* Lit_padding */0, - /* Right */1, - prec[1] - ]); + return parse_conv(/* Lit_padding */{ + 0: /* Right */1, + 1: prec[0], + length: 2, + tag: 0 + }); } } @@ -5344,26 +5508,21 @@ function fmt_ebb_of_string(legacy_behavior, str) { var plus_used = /* false */0; var sharp_used = /* false */0; var space_used = /* false */0; - var ign_used = [ - 0, - /* false */0 - ]; + var ign_used = [/* false */0]; var pad_used = /* false */0; - var prec_used = [ - 0, - /* false */0 - ]; + var prec_used = [/* false */0]; var check_no_0 = function (symb, pad) { if (typeof pad === "number") { return pad; } - else if (pad[0]) { - if (pad[1] >= 2) { + else if (pad.tag) { + if (pad[0] >= 2) { if (legacy_behavior$1) { - return [ - /* Arg_padding */1, - /* Right */1 - ]; + return /* Arg_padding */{ + 0: /* Right */1, + length: 1, + tag: 1 + }; } else { return incompatible_flag(pct_ind, str_ind, symb, "0"); @@ -5373,13 +5532,14 @@ function fmt_ebb_of_string(legacy_behavior, str) { return pad; } } - else if (pad[1] >= 2) { + else if (pad[0] >= 2) { if (legacy_behavior$1) { - return [ - /* Lit_padding */0, - /* Right */1, - pad[2] - ]; + return /* Lit_padding */{ + 0: /* Right */1, + 1: pad[1], + length: 2, + tag: 0 + }; } else { return incompatible_flag(pct_ind, str_ind, symb, "0"); @@ -5393,32 +5553,23 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (typeof pad === "number") { return /* None */0; } - else if (pad[0]) { + else if (pad.tag) { return incompatible_flag(pct_ind, str_ind, c, "'*'"); } else { - switch (pad[1]) { + switch (pad[0]) { case 0 : if (legacy_behavior$1) { - return [ - /* Some */0, - pad[2] - ]; + return /* Some */[pad[1]]; } else { return incompatible_flag(pct_ind, str_ind, c, "'-'"); } case 1 : - return [ - /* Some */0, - pad[2] - ]; + return /* Some */[pad[1]]; case 2 : if (legacy_behavior$1) { - return [ - /* Some */0, - pad[2] - ]; + return /* Some */[pad[1]]; } else { return incompatible_flag(pct_ind, str_ind, c, "'0'"); @@ -5428,7 +5579,7 @@ function fmt_ebb_of_string(legacy_behavior, str) { } }; var get_prec_opt = function () { - prec_used[1] = /* true */1; + prec_used[0] = /* true */1; if (typeof prec === "number") { if (prec !== 0) { return incompatible_flag(pct_ind, str_ind, /* "_" */95, "'*'"); @@ -5438,10 +5589,7 @@ function fmt_ebb_of_string(legacy_behavior, str) { } } else { - return [ - /* Some */0, - prec[1] - ]; + return /* Some */[prec[0]]; } }; var fmt_result; @@ -5453,49 +5601,56 @@ function fmt_ebb_of_string(legacy_behavior, str) { switch (symb) { case 33 : var match = parse_literal(str_ind, str_ind, end_ind); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Flush */10, - match[1] - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Flush */{ + 0: match[0], + length: 1, + tag: 10 + }, + length: 1, + tag: 0 + }; break; case 40 : var sub_end = search_subformat_end(str_ind, end_ind, /* ")" */41); var beg_ind = sub_end + 2; var match$1 = parse_literal(beg_ind, beg_ind, end_ind); - var fmt_rest = match$1[1]; + var fmt_rest = match$1[0]; var match$2 = parse_literal(str_ind, str_ind, sub_end); - var sub_fmtty = fmtty_of_fmt(match$2[1]); - if (ign_used[1] = /* true */1, ign) { + var sub_fmtty = fmtty_of_fmt(match$2[0]); + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_001 = opt_of_pad(/* "_" */95, pad); - var ignored = [ - /* Ignored_format_subst */8, - ignored_001, - sub_fmtty - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored, - fmt_rest - ] - ]; + var ignored_000 = opt_of_pad(/* "_" */95, pad); + var ignored = /* Ignored_format_subst */{ + 0: ignored_000, + 1: sub_fmtty, + length: 2, + tag: 8 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored, + 1: fmt_rest, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Format_subst */14, - opt_of_pad(/* "(" */40, pad), - sub_fmtty, - fmt_rest - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Format_subst */{ + 0: opt_of_pad(/* "(" */40, pad), + 1: sub_fmtty, + 2: fmt_rest, + length: 3, + tag: 14 + }, + length: 1, + tag: 0 + }; } break; case 44 : @@ -5507,118 +5662,136 @@ function fmt_ebb_of_string(legacy_behavior, str) { break; case 67 : var match$3 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$1 = match$3[1]; - fmt_result = (ign_used[1] = /* true */1, ign) ? [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - /* Ignored_caml_char */1, - fmt_rest$1 - ] - ] : [ - /* Fmt_EBB */0, - [ - /* Caml_char */1, - fmt_rest$1 - ] - ]; + var fmt_rest$1 = match$3[0]; + fmt_result = (ign_used[0] = /* true */1, ign) ? /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: /* Ignored_caml_char */1, + 1: fmt_rest$1, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + } : /* Fmt_EBB */{ + 0: /* Caml_char */{ + 0: fmt_rest$1, + length: 1, + tag: 1 + }, + length: 1, + tag: 0 + }; break; case 78 : var match$4 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$2 = match$4[1]; + var fmt_rest$2 = match$4[0]; var counter = /* Token_counter */2; - if (ign_used[1] = /* true */1, ign) { - var ignored$1 = [ - /* Ignored_scan_get_counter */10, - counter - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$1, - fmt_rest$2 - ] - ]; + if (ign_used[0] = /* true */1, ign) { + var ignored$1 = /* Ignored_scan_get_counter */{ + 0: counter, + length: 1, + tag: 10 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$1, + 1: fmt_rest$2, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Scan_get_counter */21, - counter, - fmt_rest$2 - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Scan_get_counter */{ + 0: counter, + 1: fmt_rest$2, + length: 2, + tag: 21 + }, + length: 1, + tag: 0 + }; } break; case 83 : pad_used = /* true */1; var pad$1 = check_no_0(symb, padprec); var match$5 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$3 = match$5[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$3 = match$5[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_001$1 = opt_of_pad(/* "_" */95, padprec); - var ignored$2 = [ - /* Ignored_caml_string */1, - ignored_001$1 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$2, - fmt_rest$3 - ] - ]; + var ignored$2 = /* Ignored_caml_string */{ + 0: opt_of_pad(/* "_" */95, padprec), + length: 1, + tag: 1 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$2, + 1: fmt_rest$3, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { var match$6 = make_padding_fmt_ebb(pad$1, fmt_rest$3); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Caml_string */3, - match$6[1], - match$6[2] - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Caml_string */{ + 0: match$6[0], + 1: match$6[1], + length: 2, + tag: 3 + }, + length: 1, + tag: 0 + }; } break; case 91 : var match$7 = parse_char_set(str_ind, end_ind); - var char_set = match$7[2]; - var next_ind = match$7[1]; + var char_set = match$7[1]; + var next_ind = match$7[0]; var match$8 = parse_literal(next_ind, next_ind, end_ind); - var fmt_rest$4 = match$8[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$4 = match$8[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_001$2 = opt_of_pad(/* "_" */95, pad); - var ignored$3 = [ - /* Ignored_scan_char_set */9, - ignored_001$2, - char_set - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$3, - fmt_rest$4 - ] - ]; + var ignored_000$1 = opt_of_pad(/* "_" */95, pad); + var ignored$3 = /* Ignored_scan_char_set */{ + 0: ignored_000$1, + 1: char_set, + length: 2, + tag: 9 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$3, + 1: fmt_rest$4, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Scan_char_set */20, - opt_of_pad(/* "[" */91, pad), - char_set, - fmt_rest$4 - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Scan_char_set */{ + 0: opt_of_pad(/* "[" */91, pad), + 1: char_set, + 2: fmt_rest$4, + length: 3, + tag: 20 + }, + length: 1, + tag: 0 + }; } break; case 32 : @@ -5630,13 +5803,15 @@ function fmt_ebb_of_string(legacy_behavior, str) { break; case 97 : var match$9 = parse_literal(str_ind, str_ind, end_ind); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Alpha */15, - match$9[1] - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Alpha */{ + 0: match$9[0], + length: 1, + tag: 15 + }, + length: 1, + tag: 0 + }; break; case 66 : case 98 : @@ -5644,53 +5819,61 @@ function fmt_ebb_of_string(legacy_behavior, str) { break; case 99 : var char_format = function (fmt_rest) { - if (ign_used[1] = /* true */1, ign) { - return [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - /* Ignored_char */0, - fmt_rest - ] - ]; + if (ign_used[0] = /* true */1, ign) { + return /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: /* Ignored_char */0, + 1: fmt_rest, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { - return [ - /* Fmt_EBB */0, - [ - /* Char */0, - fmt_rest - ] - ]; + return /* Fmt_EBB */{ + 0: /* Char */{ + 0: fmt_rest, + length: 1, + tag: 0 + }, + length: 1, + tag: 0 + }; } }; var scan_format = function (fmt_rest) { - if (ign_used[1] = /* true */1, ign) { - return [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - /* Ignored_scan_next_char */4, - fmt_rest - ] - ]; + if (ign_used[0] = /* true */1, ign) { + return /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: /* Ignored_scan_next_char */4, + 1: fmt_rest, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { - return [ - /* Fmt_EBB */0, - [ - /* Scan_next_char */22, - fmt_rest - ] - ]; + return /* Fmt_EBB */{ + 0: /* Scan_next_char */{ + 0: fmt_rest, + length: 1, + tag: 22 + }, + length: 1, + tag: 0 + }; } }; var match$10 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$5 = match$10[1]; + var fmt_rest$5 = match$10[0]; pad_used = /* true */1; var match$11 = opt_of_pad(/* "c" */99, pad); fmt_result = match$11 ? ( - match$11[1] !== 0 ? ( + match$11[0] !== 0 ? ( legacy_behavior$1 ? char_format(fmt_rest$5) : invalid_format_message(str_ind, "non-zero widths are unsupported for %c conversions") ) : scan_format(fmt_rest$5) ) : char_format(fmt_rest$5); @@ -5710,64 +5893,74 @@ function fmt_ebb_of_string(legacy_behavior, str) { break; case 114 : var match$12 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$6 = match$12[1]; - fmt_result = (ign_used[1] = /* true */1, ign) ? [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - /* Ignored_reader */3, - fmt_rest$6 - ] - ] : [ - /* Fmt_EBB */0, - [ - /* Reader */19, - fmt_rest$6 - ] - ]; + var fmt_rest$6 = match$12[0]; + fmt_result = (ign_used[0] = /* true */1, ign) ? /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: /* Ignored_reader */3, + 1: fmt_rest$6, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + } : /* Fmt_EBB */{ + 0: /* Reader */{ + 0: fmt_rest$6, + length: 1, + tag: 19 + }, + length: 1, + tag: 0 + }; break; case 115 : pad_used = /* true */1; var pad$2 = check_no_0(symb, padprec); var match$13 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$7 = match$13[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$7 = match$13[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_001$3 = opt_of_pad(/* "_" */95, padprec); - var ignored$4 = [ - /* Ignored_string */0, - ignored_001$3 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$4, - fmt_rest$7 - ] - ]; + var ignored$4 = /* Ignored_string */{ + 0: opt_of_pad(/* "_" */95, padprec), + length: 1, + tag: 0 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$4, + 1: fmt_rest$7, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { var match$14 = make_padding_fmt_ebb(pad$2, fmt_rest$7); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* String */2, - match$14[1], - match$14[2] - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* String */{ + 0: match$14[0], + 1: match$14[1], + length: 2, + tag: 2 + }, + length: 1, + tag: 0 + }; } break; case 116 : var match$15 = parse_literal(str_ind, str_ind, end_ind); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Theta */16, - match$15[1] - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Theta */{ + 0: match$15[0], + length: 1, + tag: 16 + }, + length: 1, + tag: 0 + }; break; case 88 : case 100 : @@ -5871,36 +6064,41 @@ function fmt_ebb_of_string(legacy_behavior, str) { var match$16 = parse_literal(str_ind, str_ind, sub_end$1); var beg_ind$1 = sub_end$1 + 2; var match$17 = parse_literal(beg_ind$1, beg_ind$1, end_ind); - var fmt_rest$8 = match$17[1]; - var sub_fmtty$1 = fmtty_of_fmt(match$16[1]); - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$8 = match$17[0]; + var sub_fmtty$1 = fmtty_of_fmt(match$16[0]); + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_001$4 = opt_of_pad(/* "_" */95, pad); - var ignored$5 = [ - /* Ignored_format_arg */7, - ignored_001$4, - sub_fmtty$1 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$5, - fmt_rest$8 - ] - ]; + var ignored_000$2 = opt_of_pad(/* "_" */95, pad); + var ignored$5 = /* Ignored_format_arg */{ + 0: ignored_000$2, + 1: sub_fmtty$1, + length: 2, + tag: 7 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$5, + 1: fmt_rest$8, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Format_arg */13, - opt_of_pad(/* "{" */123, pad), - sub_fmtty$1, - fmt_rest$8 - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Format_arg */{ + 0: opt_of_pad(/* "{" */123, pad), + 1: sub_fmtty$1, + 2: fmt_rest$8, + length: 3, + tag: 13 + }, + length: 1, + tag: 0 + }; } break; @@ -5913,27 +6111,30 @@ function fmt_ebb_of_string(legacy_behavior, str) { space_used = /* true */1; var iconv = compute_int_conv(pct_ind, str_ind, plus, sharp, space, symb); var match$18 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$9 = match$18[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$9 = match$18[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_002 = opt_of_pad(/* "_" */95, pad); - var ignored$6 = [ - /* Ignored_int */2, - iconv, - ignored_002 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$6, - fmt_rest$9 - ] - ]; + var ignored_001 = opt_of_pad(/* "_" */95, pad); + var ignored$6 = /* Ignored_int */{ + 0: iconv, + 1: ignored_001, + length: 2, + tag: 2 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$6, + 1: fmt_rest$9, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - prec_used[1] = /* true */1; + prec_used[0] = /* true */1; var pad$3; var exit$1 = 0; if (typeof prec === "number" && prec === 0) { @@ -5944,65 +6145,74 @@ function fmt_ebb_of_string(legacy_behavior, str) { } if (exit$1 === 9) { pad$3 = typeof pad === "number" ? /* No_padding */0 : ( - pad[0] ? ( - pad[1] >= 2 ? ( - legacy_behavior$1 ? [ - /* Arg_padding */1, - /* Right */1 - ] : incompatible_flag(pct_ind, str_ind, /* "0" */48, "precision") + pad.tag ? ( + pad[0] >= 2 ? ( + legacy_behavior$1 ? /* Arg_padding */{ + 0: /* Right */1, + length: 1, + tag: 1 + } : incompatible_flag(pct_ind, str_ind, /* "0" */48, "precision") ) : pad ) : ( - pad[1] >= 2 ? ( - legacy_behavior$1 ? [ - /* Lit_padding */0, - /* Right */1, - pad[2] - ] : incompatible_flag(pct_ind, str_ind, /* "0" */48, "precision") + pad[0] >= 2 ? ( + legacy_behavior$1 ? /* Lit_padding */{ + 0: /* Right */1, + 1: pad[1], + length: 2, + tag: 0 + } : incompatible_flag(pct_ind, str_ind, /* "0" */48, "precision") ) : pad ) ); } - var match$19 = make_padprec_fmt_ebb(pad$3, (prec_used[1] = /* true */1, prec), fmt_rest$9); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Int */4, - iconv, - match$19[1], - match$19[2], - match$19[3] - ] - ]; + var match$19 = make_padprec_fmt_ebb(pad$3, (prec_used[0] = /* true */1, prec), fmt_rest$9); + fmt_result = /* Fmt_EBB */{ + 0: /* Int */{ + 0: iconv, + 1: match$19[0], + 2: match$19[1], + 3: match$19[2], + length: 4, + tag: 4 + }, + length: 1, + tag: 0 + }; } break; case 2 : if (str_ind === end_ind || !is_int_base(str.charCodeAt(str_ind))) { var match$20 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$10 = match$20[1]; + var fmt_rest$10 = match$20[0]; var counter$1 = counter_of_char(symb); - if (ign_used[1] = /* true */1, ign) { - var ignored$7 = [ - /* Ignored_scan_get_counter */10, - counter$1 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$7, - fmt_rest$10 - ] - ]; + if (ign_used[0] = /* true */1, ign) { + var ignored$7 = /* Ignored_scan_get_counter */{ + 0: counter$1, + length: 1, + tag: 10 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$7, + 1: fmt_rest$10, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Scan_get_counter */21, - counter$1, - fmt_rest$10 - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Scan_get_counter */{ + 0: counter$1, + 1: fmt_rest$10, + length: 2, + tag: 21 + }, + length: 1, + tag: 0 + }; } } else { @@ -6014,112 +6224,133 @@ function fmt_ebb_of_string(legacy_behavior, str) { space_used = /* true */1; var fconv = compute_float_conv(pct_ind, str_ind, plus, space, symb); var match$21 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$11 = match$21[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$11 = match$21[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_001$5 = opt_of_pad(/* "_" */95, pad); - var ignored_002$1 = get_prec_opt(/* () */0); - var ignored$8 = [ - /* Ignored_float */6, - ignored_001$5, - ignored_002$1 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$8, - fmt_rest$11 - ] - ]; + var ignored_000$3 = opt_of_pad(/* "_" */95, pad); + var ignored_001$1 = get_prec_opt(/* () */0); + var ignored$8 = /* Ignored_float */{ + 0: ignored_000$3, + 1: ignored_001$1, + length: 2, + tag: 6 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$8, + 1: fmt_rest$11, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - var match$22 = make_padprec_fmt_ebb(pad, (prec_used[1] = /* true */1, prec), fmt_rest$11); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Float */8, - fconv, - match$22[1], - match$22[2], - match$22[3] - ] - ]; + var match$22 = make_padprec_fmt_ebb(pad, (prec_used[0] = /* true */1, prec), fmt_rest$11); + fmt_result = /* Fmt_EBB */{ + 0: /* Float */{ + 0: fconv, + 1: match$22[0], + 2: match$22[1], + 3: match$22[2], + length: 4, + tag: 8 + }, + length: 1, + tag: 0 + }; } break; case 4 : var match$23 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$12 = match$23[1]; - fmt_result = (ign_used[1] = /* true */1, ign) ? [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - /* Ignored_bool */2, - fmt_rest$12 - ] - ] : [ - /* Fmt_EBB */0, - [ - /* Bool */9, - fmt_rest$12 - ] - ]; + var fmt_rest$12 = match$23[0]; + fmt_result = (ign_used[0] = /* true */1, ign) ? /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: /* Ignored_bool */2, + 1: fmt_rest$12, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + } : /* Fmt_EBB */{ + 0: /* Bool */{ + 0: fmt_rest$12, + length: 1, + tag: 9 + }, + length: 1, + tag: 0 + }; break; case 5 : var match$24 = parse_literal(str_ind, str_ind, end_ind); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Char_literal */12, - symb, - match$24[1] - ] - ]; + fmt_result = /* Fmt_EBB */{ + 0: /* Char_literal */{ + 0: symb, + 1: match$24[0], + length: 2, + tag: 12 + }, + length: 1, + tag: 0 + }; break; case 6 : - fmt_result = Caml_curry.app3(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": at character number ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", flag ", - [ - /* Caml_char */1, - [ - /* String_literal */11, - " is only allowed after the '", - [ - /* Char_literal */12, - /* "%" */37, - [ - /* String_literal */11, - "', before padding and precision", - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ] - ], - "invalid format %S: at character number %d, flag %C is only allowed after the '%%', before padding and precision" - ]), str, pct_ind, symb); + fmt_result = Caml_curry.app3(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": at character number ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", flag ", + 1: /* Caml_char */{ + 0: /* String_literal */{ + 0: " is only allowed after the '", + 1: /* Char_literal */{ + 0: /* "%" */37, + 1: /* String_literal */{ + 0: "', before padding and precision", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 11 + }, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: at character number %d, flag %C is only allowed after the '%%', before padding and precision", + length: 2, + tag: 0 + }), str, pct_ind, symb); break; case 7 : if (symb >= 108) { @@ -6135,37 +6366,42 @@ function fmt_ebb_of_string(legacy_behavior, str) { var iconv$1 = compute_int_conv(pct_ind, str_ind + 1, plus, sharp, space, str.charCodeAt(str_ind)); var beg_ind$2 = str_ind + 1; var match$25 = parse_literal(beg_ind$2, beg_ind$2, end_ind); - var fmt_rest$13 = match$25[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$13 = match$25[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_002$2 = opt_of_pad(/* "_" */95, pad); - var ignored$9 = [ - /* Ignored_int32 */3, - iconv$1, - ignored_002$2 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$9, - fmt_rest$13 - ] - ]; + var ignored_001$2 = opt_of_pad(/* "_" */95, pad); + var ignored$9 = /* Ignored_int32 */{ + 0: iconv$1, + 1: ignored_001$2, + length: 2, + tag: 3 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$9, + 1: fmt_rest$13, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - var match$26 = make_padprec_fmt_ebb(pad, (prec_used[1] = /* true */1, prec), fmt_rest$13); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Int32 */5, - iconv$1, - match$26[1], - match$26[2], - match$26[3] - ] - ]; + var match$26 = make_padprec_fmt_ebb(pad, (prec_used[0] = /* true */1, prec), fmt_rest$13); + fmt_result = /* Fmt_EBB */{ + 0: /* Int32 */{ + 0: iconv$1, + 1: match$26[0], + 2: match$26[1], + 3: match$26[2], + length: 4, + tag: 5 + }, + length: 1, + tag: 0 + }; } break; case 1 : @@ -6178,37 +6414,42 @@ function fmt_ebb_of_string(legacy_behavior, str) { var iconv$2 = compute_int_conv(pct_ind, str_ind + 1, plus, sharp, space, str.charCodeAt(str_ind)); var beg_ind$3 = str_ind + 1; var match$27 = parse_literal(beg_ind$3, beg_ind$3, end_ind); - var fmt_rest$14 = match$27[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$14 = match$27[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_002$3 = opt_of_pad(/* "_" */95, pad); - var ignored$10 = [ - /* Ignored_nativeint */4, - iconv$2, - ignored_002$3 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$10, - fmt_rest$14 - ] - ]; + var ignored_001$3 = opt_of_pad(/* "_" */95, pad); + var ignored$10 = /* Ignored_nativeint */{ + 0: iconv$2, + 1: ignored_001$3, + length: 2, + tag: 4 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$10, + 1: fmt_rest$14, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - var match$28 = make_padprec_fmt_ebb(pad, (prec_used[1] = /* true */1, prec), fmt_rest$14); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Nativeint */6, - iconv$2, - match$28[1], - match$28[2], - match$28[3] - ] - ]; + var match$28 = make_padprec_fmt_ebb(pad, (prec_used[0] = /* true */1, prec), fmt_rest$14); + fmt_result = /* Fmt_EBB */{ + 0: /* Nativeint */{ + 0: iconv$2, + 1: match$28[0], + 2: match$28[1], + 3: match$28[2], + length: 4, + tag: 6 + }, + length: 1, + tag: 0 + }; } break; @@ -6225,79 +6466,93 @@ function fmt_ebb_of_string(legacy_behavior, str) { var iconv$3 = compute_int_conv(pct_ind, str_ind + 1, plus, sharp, space, str.charCodeAt(str_ind)); var beg_ind$4 = str_ind + 1; var match$29 = parse_literal(beg_ind$4, beg_ind$4, end_ind); - var fmt_rest$15 = match$29[1]; - if (ign_used[1] = /* true */1, ign) { + var fmt_rest$15 = match$29[0]; + if (ign_used[0] = /* true */1, ign) { pad_used = /* true */1; - var ignored_002$4 = opt_of_pad(/* "_" */95, pad); - var ignored$11 = [ - /* Ignored_int64 */5, - iconv$3, - ignored_002$4 - ]; - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Ignored_param */23, - ignored$11, - fmt_rest$15 - ] - ]; + var ignored_001$4 = opt_of_pad(/* "_" */95, pad); + var ignored$11 = /* Ignored_int64 */{ + 0: iconv$3, + 1: ignored_001$4, + length: 2, + tag: 5 + }; + fmt_result = /* Fmt_EBB */{ + 0: /* Ignored_param */{ + 0: ignored$11, + 1: fmt_rest$15, + length: 2, + tag: 23 + }, + length: 1, + tag: 0 + }; } else { pad_used = /* true */1; - var match$30 = make_padprec_fmt_ebb(pad, (prec_used[1] = /* true */1, prec), fmt_rest$15); - fmt_result = [ - /* Fmt_EBB */0, - [ - /* Int64 */7, - iconv$3, - match$30[1], - match$30[2], - match$30[3] - ] - ]; + var match$30 = make_padprec_fmt_ebb(pad, (prec_used[0] = /* true */1, prec), fmt_rest$15); + fmt_result = /* Fmt_EBB */{ + 0: /* Int64 */{ + 0: iconv$3, + 1: match$30[0], + 2: match$30[1], + 3: match$30[2], + length: 4, + tag: 7 + }, + length: 1, + tag: 0 + }; } } break; case 8 : - fmt_result = Caml_curry.app3(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": at character number ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ', invalid conversion "', - [ - /* Char_literal */12, - /* "%" */37, - [ - /* Char */0, - [ - /* Char_literal */12, - /* "\"" */34, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ], - 'invalid format %S: at character number %d, invalid conversion "%%%c"' - ]), str, str_ind - 1, symb); + fmt_result = Caml_curry.app3(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": at character number ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ', invalid conversion "', + 1: /* Char_literal */{ + 0: /* "%" */37, + 1: /* Char */{ + 0: /* Char_literal */{ + 0: /* "\"" */34, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 1, + tag: 0 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: 'invalid format %S: at character number %d, invalid conversion "%%%c"', + length: 2, + tag: 0 + }), str, str_ind - 1, symb); break; } @@ -6311,22 +6566,26 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (!space_used && space) { incompatible_flag(pct_ind, str_ind, symb, "' '"); } - if (!pad_used && Caml_primitive.caml_notequal([ - /* Padding_EBB */0, - pad - ], [ - /* Padding_EBB */0, - /* No_padding */0 - ])) { + if (!pad_used && Caml_obj.caml_notequal(/* Padding_EBB */{ + 0: pad, + length: 1, + tag: 0 + }, /* Padding_EBB */{ + 0: /* No_padding */0, + length: 1, + tag: 0 + })) { incompatible_flag(pct_ind, str_ind, symb, "`padding'"); } - if (!prec_used[1] && Caml_primitive.caml_notequal([ - /* Precision_EBB */0, - prec - ], [ - /* Precision_EBB */0, - /* No_precision */0 - ])) { + if (!prec_used[0] && Caml_obj.caml_notequal(/* Precision_EBB */{ + 0: prec, + length: 1, + tag: 0 + }, /* Precision_EBB */{ + 0: /* No_precision */0, + length: 1, + tag: 0 + })) { incompatible_flag(pct_ind, str_ind, ign ? /* "_" */95 : symb, "`precision'"); } if (ign && plus) { @@ -6334,7 +6593,7 @@ function fmt_ebb_of_string(legacy_behavior, str) { } } - if (!ign_used[1] && ign) { + if (!ign_used[0] && ign) { var exit$2 = 0; if (symb >= 38) { if (symb !== 44) { @@ -6374,14 +6633,16 @@ function fmt_ebb_of_string(legacy_behavior, str) { }; var parse_after_at = function (str_ind, end_ind) { if (str_ind === end_ind) { - return [ - /* Fmt_EBB */0, - [ - /* Char_literal */12, - /* "@" */64, - /* End_of_format */0 - ] - ]; + return /* Fmt_EBB */{ + 0: /* Char_literal */{ + 0: /* "@" */64, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 1, + tag: 0 + }; } else { var c = str.charCodeAt(str_ind); @@ -6402,14 +6663,16 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 2 : var beg_ind = str_ind + 1; var match = parse_literal(beg_ind, beg_ind, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - /* Close_tag */1, - match[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Close_tag */1, + 1: match[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } } @@ -6424,14 +6687,16 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 2 : var beg_ind$1 = str_ind + 1; var match$1 = parse_literal(beg_ind$1, beg_ind$1, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - /* Close_box */0, - match$1[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Close_box */0, + 1: match$1[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } } @@ -6445,71 +6710,83 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 0 : var beg_ind$2 = str_ind + 1; var match$2 = parse_literal(beg_ind$2, beg_ind$2, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - [ - /* Break */0, - "@ ", - 1, - 0 - ], - match$2[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Break */{ + 0: "@ ", + 1: 1, + 2: 0, + length: 3, + tag: 0 + }, + 1: match$2[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; case 5 : if (str_ind + 1 < end_ind && str[str_ind + 1] === "%") { var beg_ind$3 = str_ind + 2; var match$3 = parse_literal(beg_ind$3, beg_ind$3, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - /* Escaped_percent */6, - match$3[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Escaped_percent */6, + 1: match$3[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } else { var match$4 = parse_literal(str_ind, str_ind, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Char_literal */12, - /* "@" */64, - match$4[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Char_literal */{ + 0: /* "@" */64, + 1: match$4[0], + length: 2, + tag: 12 + }, + length: 1, + tag: 0 + }; } break; case 12 : var beg_ind$4 = str_ind + 1; var match$5 = parse_literal(beg_ind$4, beg_ind$4, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - [ - /* Break */0, - "@,", - 0, - 0 - ], - match$5[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Break */{ + 0: "@,", + 1: 0, + 2: 0, + length: 3, + tag: 0 + }, + 1: match$5[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; case 14 : var beg_ind$5 = str_ind + 1; var match$6 = parse_literal(beg_ind$5, beg_ind$5, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - /* Flush_newline */4, - match$6[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Flush_newline */4, + 1: match$6[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; case 27 : var str_ind$1 = str_ind + 1; var end_ind$1 = end_ind; @@ -6537,8 +6814,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { } if (exit$1 === 1) { var match$9 = parse_integer(str_ind_1, end_ind$1); - var width = match$9[2]; - var str_ind_3 = parse_spaces(match$9[1], end_ind$1); + var width = match$9[1]; + var str_ind_3 = parse_spaces(match$9[0], end_ind$1); var match$10 = str.charCodeAt(str_ind_3); var switcher$1 = match$10 - 45; if (switcher$1 > 12 || switcher$1 < 0) { @@ -6547,15 +6824,15 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else { var s = $$String.sub(str, str_ind$1 - 2, str_ind_3 - str_ind$1 + 3); - match$7 = [ - /* tuple */0, + match$7 = /* tuple */[ str_ind_3 + 1, - [ - /* Break */0, - s, - width, - 0 - ] + /* Break */{ + 0: s, + 1: width, + 2: 0, + length: 3, + tag: 0 + } ]; } } @@ -6564,20 +6841,20 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else { var match$11 = parse_integer(str_ind_3, end_ind$1); - var str_ind_5 = parse_spaces(match$11[1], end_ind$1); + var str_ind_5 = parse_spaces(match$11[0], end_ind$1); if (str.charCodeAt(str_ind_5) !== /* ">" */62) { throw Caml_builtin_exceptions.Not_found; } var s$1 = $$String.sub(str, str_ind$1 - 2, str_ind_5 - str_ind$1 + 3); - match$7 = [ - /* tuple */0, + match$7 = /* tuple */[ str_ind_5 + 1, - [ - /* Break */0, - s$1, - width, - match$11[2] - ] + /* Break */{ + 0: s$1, + 1: width, + 2: match$11[1], + length: 3, + tag: 0 + } ]; } } @@ -6585,43 +6862,45 @@ function fmt_ebb_of_string(legacy_behavior, str) { } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - match$7 = [ - /* tuple */0, + match$7 = /* tuple */[ str_ind$1, - [ - /* Break */0, - "@;", - 1, - 0 - ] + /* Break */{ + 0: "@;", + 1: 1, + 2: 0, + length: 3, + tag: 0 + } ]; } - else if (exn[1] === Caml_builtin_exceptions.Failure) { - match$7 = [ - /* tuple */0, + else if (exn[0] === Caml_builtin_exceptions.Failure) { + match$7 = /* tuple */[ str_ind$1, - [ - /* Break */0, - "@;", - 1, - 0 - ] + /* Break */{ + 0: "@;", + 1: 1, + 2: 0, + length: 3, + tag: 0 + } ]; } else { throw exn; } } - var next_ind = match$7[1]; + var next_ind = match$7[0]; var match$12 = parse_literal(next_ind, next_ind, end_ind$1); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - match$7[2], - match$12[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: match$7[1], + 1: match$12[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; case 28 : var str_ind$2 = str_ind + 1; var end_ind$2 = end_ind; @@ -6646,23 +6925,20 @@ function fmt_ebb_of_string(legacy_behavior, str) { } if (exit$2 === 1) { var match$15 = parse_integer(str_ind_1$1, end_ind$2); - var str_ind_3$1 = parse_spaces(match$15[1], end_ind$2); + var str_ind_3$1 = parse_spaces(match$15[0], end_ind$2); if (str.charCodeAt(str_ind_3$1) !== /* ">" */62) { throw Caml_builtin_exceptions.Not_found; } var s$2 = $$String.sub(str, str_ind$2 - 2, str_ind_3$1 - str_ind$2 + 3); - match$13 = [ - /* Some */0, - [ - /* tuple */0, + match$13 = /* Some */[/* tuple */[ str_ind_3$1 + 1, - [ - /* Magic_size */1, - s$2, - match$15[2] - ] - ] - ]; + /* Magic_size */{ + 0: s$2, + 1: match$15[1], + length: 2, + tag: 1 + } + ]]; } } @@ -6670,7 +6946,7 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (exn$1 === Caml_builtin_exceptions.Not_found) { match$13 = /* None */0; } - else if (exn$1[1] === Caml_builtin_exceptions.Failure) { + else if (exn$1[0] === Caml_builtin_exceptions.Failure) { match$13 = /* None */0; } else { @@ -6678,31 +6954,36 @@ function fmt_ebb_of_string(legacy_behavior, str) { } } if (match$13) { - var match$16 = match$13[1]; - var next_ind$1 = match$16[1]; + var match$16 = match$13[0]; + var next_ind$1 = match$16[0]; var match$17 = parse_literal(next_ind$1, next_ind$1, end_ind$2); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - match$16[2], - match$17[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: match$16[1], + 1: match$17[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } else { var match$18 = parse_literal(str_ind$2, str_ind$2, end_ind$2); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - [ - /* Scan_indic */2, - /* "<" */60 - ], - match$18[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Scan_indic */{ + 0: /* "<" */60, + length: 1, + tag: 2 + }, + 1: match$18[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } case 1 : case 2 : @@ -6734,25 +7015,29 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 31 : var beg_ind$6 = str_ind + 1; var match$19 = parse_literal(beg_ind$6, beg_ind$6, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - /* FFlush */2, - match$19[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* FFlush */2, + 1: match$19[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; case 32 : var beg_ind$7 = str_ind + 1; var match$20 = parse_literal(beg_ind$7, beg_ind$7, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - /* Escaped_at */5, - match$20[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Escaped_at */5, + 1: match$20[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } } @@ -6763,29 +7048,34 @@ function fmt_ebb_of_string(legacy_behavior, str) { else { var beg_ind$8 = str_ind + 1; var match$21 = parse_literal(beg_ind$8, beg_ind$8, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - /* Force_newline */3, - match$21[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Force_newline */3, + 1: match$21[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } if (exit === 1) { var beg_ind$9 = str_ind + 1; var match$22 = parse_literal(beg_ind$9, beg_ind$9, end_ind); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_lit */17, - [ - /* Scan_indic */2, - c - ], - match$22[1] - ] - ]; + return /* Fmt_EBB */{ + 0: /* Formatting_lit */{ + 0: /* Scan_indic */{ + 0: c, + length: 1, + tag: 2 + }, + 1: match$22[0], + length: 2, + tag: 17 + }, + length: 1, + tag: 0 + }; } } @@ -6794,13 +7084,13 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (typeof fmt === "number") { return /* () */0; } - else if (fmt[0] === 11) { - if (typeof fmt[2] === "number") { + else if (fmt.tag === 11) { + if (typeof fmt[1] === "number") { try { - return open_box_of_string(fmt[1]); + return open_box_of_string(fmt[0]); } catch (exn){ - if (exn[1] === Caml_builtin_exceptions.Failure) { + if (exn[0] === Caml_builtin_exceptions.Failure) { return /* () */0; } else { @@ -6834,52 +7124,62 @@ function fmt_ebb_of_string(legacy_behavior, str) { var beg_ind = ind + 1; var match$1 = parse_literal(beg_ind, beg_ind, end_ind); var match$2 = parse_literal(str_ind, str_ind, ind + 1); - var sub_fmt = match$2[1]; - var sub_format = [ - /* Format */0, - sub_fmt, - sub_str - ]; - var formatting = is_open_tag ? [ - /* Open_tag */0, - sub_format - ] : (check_open_box(sub_fmt), [ - /* Open_box */1, - sub_format - ]); - return [ - /* Fmt_EBB */0, - [ - /* Formatting_gen */18, - formatting, - match$1[1] - ] - ]; + var sub_fmt = match$2[0]; + var sub_format = /* Format */{ + 0: sub_fmt, + 1: sub_str, + length: 2, + tag: 0 + }; + var formatting = is_open_tag ? /* Open_tag */{ + 0: sub_format, + length: 1, + tag: 0 + } : (check_open_box(sub_fmt), /* Open_box */{ + 0: sub_format, + length: 1, + tag: 1 + }); + return /* Fmt_EBB */{ + 0: /* Formatting_gen */{ + 0: formatting, + 1: match$1[0], + length: 2, + tag: 18 + }, + length: 1, + tag: 0 + }; } } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { var match$3 = parse_literal(str_ind, str_ind, end_ind); - var sub_format$1 = [ - /* Format */0, - /* End_of_format */0, - "" - ]; - var formatting$1 = is_open_tag ? [ - /* Open_tag */0, - sub_format$1 - ] : [ - /* Open_box */1, - sub_format$1 - ]; - return [ - /* Fmt_EBB */0, - [ - /* Formatting_gen */18, - formatting$1, - match$3[1] - ] - ]; + var sub_format$1 = /* Format */{ + 0: /* End_of_format */0, + 1: "", + length: 2, + tag: 0 + }; + var formatting$1 = is_open_tag ? /* Open_tag */{ + 0: sub_format$1, + length: 1, + tag: 0 + } : /* Open_box */{ + 0: sub_format$1, + length: 1, + tag: 1 + }; + return /* Fmt_EBB */{ + 0: /* Formatting_gen */{ + 0: formatting$1, + 1: match$3[0], + length: 2, + tag: 18 + }, + length: 1, + tag: 0 + }; } else { throw exn; @@ -6898,53 +7198,64 @@ function fmt_ebb_of_string(legacy_behavior, str) { return /* () */0; }; var fail_single_percent = function (str_ind) { - return Caml_curry.app2(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": '", - [ - /* Char_literal */12, - /* "%" */37, - [ - /* String_literal */11, - "' alone is not accepted in character sets, use ", - [ - /* Char_literal */12, - /* "%" */37, - [ - /* Char_literal */12, - /* "%" */37, - [ - /* String_literal */11, - " instead at position ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "." */46, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ], - "invalid format %S: '%%' alone is not accepted in character sets, use %%%% instead at position %d." - ]), str, str_ind); + return Caml_curry.app2(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": '", + 1: /* Char_literal */{ + 0: /* "%" */37, + 1: /* String_literal */{ + 0: "' alone is not accepted in character sets, use ", + 1: /* Char_literal */{ + 0: /* "%" */37, + 1: /* Char_literal */{ + 0: /* "%" */37, + 1: /* String_literal */{ + 0: " instead at position ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "." */46, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: '%%' alone is not accepted in character sets, use %%%% instead at position %d.", + length: 2, + tag: 0 + }), str, str_ind); }; var parse_char_set_start = function (str_ind, end_ind) { if (str_ind === end_ind) { @@ -7076,21 +7387,18 @@ function fmt_ebb_of_string(legacy_behavior, str) { invalid_format_message(end_ind, "unexpected end of format"); } var match = str.charCodeAt(str_ind); - var match$1 = match !== 94 ? [ - /* tuple */0, + var match$1 = match !== 94 ? /* tuple */[ str_ind, /* false */0 - ] : [ - /* tuple */0, + ] : /* tuple */[ str_ind + 1, /* true */1 ]; - var next_ind = parse_char_set_start(match$1[1], end_ind); + var next_ind = parse_char_set_start(match$1[0], end_ind); var char_set$1 = Bytes.to_string(char_set); - return [ - /* tuple */0, + return /* tuple */[ next_ind, - match$1[2] ? rev_char_set(char_set$1) : char_set$1 + match$1[1] ? rev_char_set(char_set$1) : char_set$1 ]; }; var parse_spaces = function (_str_ind, end_ind) { @@ -7118,8 +7426,7 @@ function fmt_ebb_of_string(legacy_behavior, str) { } var c = str.charCodeAt(str_ind); if (c > 57 || c < 48) { - return [ - /* tuple */0, + return /* tuple */[ str_ind, acc ]; @@ -7127,39 +7434,46 @@ function fmt_ebb_of_string(legacy_behavior, str) { else { var new_acc = acc * 10 + (c - /* "0" */48); if (new_acc > Sys.max_string_length) { - return Caml_curry.app3(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": integer ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - " is greater than the limit ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 - ] - ] - ] - ] - ] - ], - "invalid format %S: integer %d is greater than the limit %d" - ]), str, new_acc, Sys.max_string_length); + return Caml_curry.app3(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": integer ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: " is greater than the limit ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: integer %d is greater than the limit %d", + length: 2, + tag: 0 + }), str, new_acc, Sys.max_string_length); } else { _acc = new_acc; @@ -7178,10 +7492,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (match >= 48) { if (match >= 58) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 2621, 11 @@ -7194,10 +7506,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else if (match !== 45) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 2621, 11 @@ -7214,10 +7524,9 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else { var match$1 = parse_positive(str_ind + 1, end_ind, 0); - return [ - /* tuple */0, - match$1[1], - -match$1[2] + return /* tuple */[ + match$1[0], + -match$1[1] ]; } } @@ -7226,71 +7535,84 @@ function fmt_ebb_of_string(legacy_behavior, str) { var size = str_ind - lit_start; if (size !== 0) { if (size !== 1) { - return [ - /* Fmt_EBB */0, - [ - /* String_literal */11, - $$String.sub(str, lit_start, size), - fmt - ] - ]; + return /* Fmt_EBB */{ + 0: /* String_literal */{ + 0: $$String.sub(str, lit_start, size), + 1: fmt, + length: 2, + tag: 11 + }, + length: 1, + tag: 0 + }; } else { - return [ - /* Fmt_EBB */0, - [ - /* Char_literal */12, - str.charCodeAt(lit_start), - fmt - ] - ]; + return /* Fmt_EBB */{ + 0: /* Char_literal */{ + 0: str.charCodeAt(lit_start), + 1: fmt, + length: 2, + tag: 12 + }, + length: 1, + tag: 0 + }; } } else { - return [ - /* Fmt_EBB */0, - fmt - ]; + return /* Fmt_EBB */{ + 0: fmt, + length: 1, + tag: 0 + }; } }; var search_subformat_end = function (_str_ind, end_ind, c) { while(true) { var str_ind = _str_ind; if (str_ind === end_ind) { - Caml_curry.app3(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ': unclosed sub-format, expected "', - [ - /* Char_literal */12, - /* "%" */37, - [ - /* Char */0, - [ - /* String_literal */11, - '" at character number ', - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ], - 'invalid format %S: unclosed sub-format, expected "%%%c" at character number %d' - ]), str, c, end_ind); + Caml_curry.app3(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ': unclosed sub-format, expected "', + 1: /* Char_literal */{ + 0: /* "%" */37, + 1: /* Char */{ + 0: /* String_literal */{ + 0: '" at character number ', + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 1, + tag: 0 + }, + length: 2, + tag: 12 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: 'invalid format %S: unclosed sub-format, expected "%%%c" at character number %d', + length: 2, + tag: 0 + }), str, c, end_ind); } var match = str.charCodeAt(str_ind); if (match !== 37) { @@ -7454,10 +7776,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { } if (exit === 1) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 2683, 34 @@ -7691,10 +8011,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 2716, 28 @@ -7818,10 +8136,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { var switcher$2 = symb - 101; if (switcher$2 > 2 || switcher$2 < 0) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 2744, 25 @@ -7853,10 +8169,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalFormat.ml", 2744, 25 @@ -7867,52 +8181,63 @@ function fmt_ebb_of_string(legacy_behavior, str) { }; var incompatible_flag = function (pct_ind, str_ind, symb, option) { var subfmt = $$String.sub(str, pct_ind, str_ind - pct_ind); - return Caml_curry.app5(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - ": at character number ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", ", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - " is incompatible with '", - [ - /* Char */0, - [ - /* String_literal */11, - "' in sub-format ", - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ], - "invalid format %S: at character number %d, %s is incompatible with '%c' in sub-format %S" - ]), str, pct_ind, option, symb, subfmt); + return Caml_curry.app5(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "invalid format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ": at character number ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " is incompatible with '", + 1: /* Char */{ + 0: /* String_literal */{ + 0: "' in sub-format ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + length: 1, + tag: 0 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid format %S: at character number %d, %s is incompatible with '%c' in sub-format %S", + length: 2, + tag: 0 + }), str, pct_ind, option, symb, subfmt); }; return parse_literal(0, 0, str.length); } @@ -7920,35 +8245,41 @@ function fmt_ebb_of_string(legacy_behavior, str) { function format_of_string_fmtty(str, fmtty) { var match = fmt_ebb_of_string(/* None */0, str); try { - return [ - /* Format */0, - type_format(match[1], fmtty), - str - ]; + return /* Format */{ + 0: type_format(match[0], fmtty), + 1: str, + length: 2, + tag: 0 + }; } catch (exn){ if (exn === Type_mismatch) { - return Caml_curry.app2(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "bad input: format type mismatch between ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - " and ", - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ] - ], - "bad input: format type mismatch between %S and %S" - ]), str, string_of_fmtty(fmtty)); + return Caml_curry.app2(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "bad input: format type mismatch between ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " and ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "bad input: format type mismatch between %S and %S", + length: 2, + tag: 0 + }), str, string_of_fmtty(fmtty)); } else { throw exn; @@ -7959,35 +8290,41 @@ function format_of_string_fmtty(str, fmtty) { function format_of_string_format(str, param) { var match = fmt_ebb_of_string(/* None */0, str); try { - return [ - /* Format */0, - type_format(match[1], fmtty_of_fmt(param[1])), - str - ]; + return /* Format */{ + 0: type_format(match[0], fmtty_of_fmt(param[0])), + 1: str, + length: 2, + tag: 0 + }; } catch (exn){ if (exn === Type_mismatch) { - return Caml_curry.app2(failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "bad input: format type mismatch between ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* String_literal */11, - " and ", - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ] - ], - "bad input: format type mismatch between %S and %S" - ]), str, param[2]); + return Caml_curry.app2(failwith_message(/* Format */{ + 0: /* String_literal */{ + 0: "bad input: format type mismatch between ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " and ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "bad input: format type mismatch between %S and %S", + length: 2, + tag: 0 + }), str, param[1]); } else { throw exn; diff --git a/jscomp/stdlib/camlinternalFormatBasics.js b/jscomp/stdlib/camlinternalFormatBasics.js index d150da2b2f..f5c9068c78 100644 --- a/jscomp/stdlib/camlinternalFormatBasics.js +++ b/jscomp/stdlib/camlinternalFormatBasics.js @@ -7,86 +7,101 @@ function erase_rel(param) { return /* End_of_fmtty */0; } else { - switch (param[0]) { + switch (param.tag | 0) { case 0 : - return [ - /* Char_ty */0, - erase_rel(param[1]) - ]; + return /* Char_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 0 + }; case 1 : - return [ - /* String_ty */1, - erase_rel(param[1]) - ]; + return /* String_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 1 + }; case 2 : - return [ - /* Int_ty */2, - erase_rel(param[1]) - ]; + return /* Int_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 2 + }; case 3 : - return [ - /* Int32_ty */3, - erase_rel(param[1]) - ]; + return /* Int32_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 3 + }; case 4 : - return [ - /* Nativeint_ty */4, - erase_rel(param[1]) - ]; + return /* Nativeint_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 4 + }; case 5 : - return [ - /* Int64_ty */5, - erase_rel(param[1]) - ]; + return /* Int64_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 5 + }; case 6 : - return [ - /* Float_ty */6, - erase_rel(param[1]) - ]; + return /* Float_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 6 + }; case 7 : - return [ - /* Bool_ty */7, - erase_rel(param[1]) - ]; + return /* Bool_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 7 + }; case 8 : - return [ - /* Format_arg_ty */8, - param[1], - erase_rel(param[2]) - ]; + return /* Format_arg_ty */{ + 0: param[0], + 1: erase_rel(param[1]), + length: 2, + tag: 8 + }; case 9 : - var ty1 = param[1]; - return [ - /* Format_subst_ty */9, - ty1, - ty1, - erase_rel(param[3]) - ]; + var ty1 = param[0]; + return /* Format_subst_ty */{ + 0: ty1, + 1: ty1, + 2: erase_rel(param[2]), + length: 3, + tag: 9 + }; case 10 : - return [ - /* Alpha_ty */10, - erase_rel(param[1]) - ]; + return /* Alpha_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 10 + }; case 11 : - return [ - /* Theta_ty */11, - erase_rel(param[1]) - ]; + return /* Theta_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 11 + }; case 12 : - return [ - /* Any_ty */12, - erase_rel(param[1]) - ]; + return /* Any_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 12 + }; case 13 : - return [ - /* Reader_ty */13, - erase_rel(param[1]) - ]; + return /* Reader_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 13 + }; case 14 : - return [ - /* Ignored_reader_ty */14, - erase_rel(param[1]) - ]; + return /* Ignored_reader_ty */{ + 0: erase_rel(param[0]), + length: 1, + tag: 14 + }; } } @@ -97,85 +112,100 @@ function concat_fmtty(fmtty1, fmtty2) { return fmtty2; } else { - switch (fmtty1[0]) { + switch (fmtty1.tag | 0) { case 0 : - return [ - /* Char_ty */0, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Char_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 0 + }; case 1 : - return [ - /* String_ty */1, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* String_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 1 + }; case 2 : - return [ - /* Int_ty */2, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Int_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 2 + }; case 3 : - return [ - /* Int32_ty */3, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Int32_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 3 + }; case 4 : - return [ - /* Nativeint_ty */4, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Nativeint_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 4 + }; case 5 : - return [ - /* Int64_ty */5, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Int64_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 5 + }; case 6 : - return [ - /* Float_ty */6, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Float_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 6 + }; case 7 : - return [ - /* Bool_ty */7, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Bool_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 7 + }; case 8 : - return [ - /* Format_arg_ty */8, - fmtty1[1], - concat_fmtty(fmtty1[2], fmtty2) - ]; + return /* Format_arg_ty */{ + 0: fmtty1[0], + 1: concat_fmtty(fmtty1[1], fmtty2), + length: 2, + tag: 8 + }; case 9 : - return [ - /* Format_subst_ty */9, - fmtty1[1], - fmtty1[2], - concat_fmtty(fmtty1[3], fmtty2) - ]; + return /* Format_subst_ty */{ + 0: fmtty1[0], + 1: fmtty1[1], + 2: concat_fmtty(fmtty1[2], fmtty2), + length: 3, + tag: 9 + }; case 10 : - return [ - /* Alpha_ty */10, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Alpha_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 10 + }; case 11 : - return [ - /* Theta_ty */11, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Theta_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 11 + }; case 12 : - return [ - /* Any_ty */12, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Any_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 12 + }; case 13 : - return [ - /* Reader_ty */13, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Reader_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 13 + }; case 14 : - return [ - /* Ignored_reader_ty */14, - concat_fmtty(fmtty1[1], fmtty2) - ]; + return /* Ignored_reader_ty */{ + 0: concat_fmtty(fmtty1[0], fmtty2), + length: 1, + tag: 14 + }; } } @@ -186,163 +216,188 @@ function concat_fmt(fmt1, fmt2) { return fmt2; } else { - switch (fmt1[0]) { + switch (fmt1.tag | 0) { case 0 : - return [ - /* Char */0, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Char */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 0 + }; case 1 : - return [ - /* Caml_char */1, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Caml_char */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 1 + }; case 2 : - return [ - /* String */2, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* String */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 2 + }; case 3 : - return [ - /* Caml_string */3, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* Caml_string */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 3 + }; case 4 : - return [ - /* Int */4, - fmt1[1], - fmt1[2], - fmt1[3], - concat_fmt(fmt1[4], fmt2) - ]; + return /* Int */{ + 0: fmt1[0], + 1: fmt1[1], + 2: fmt1[2], + 3: concat_fmt(fmt1[3], fmt2), + length: 4, + tag: 4 + }; case 5 : - return [ - /* Int32 */5, - fmt1[1], - fmt1[2], - fmt1[3], - concat_fmt(fmt1[4], fmt2) - ]; + return /* Int32 */{ + 0: fmt1[0], + 1: fmt1[1], + 2: fmt1[2], + 3: concat_fmt(fmt1[3], fmt2), + length: 4, + tag: 5 + }; case 6 : - return [ - /* Nativeint */6, - fmt1[1], - fmt1[2], - fmt1[3], - concat_fmt(fmt1[4], fmt2) - ]; + return /* Nativeint */{ + 0: fmt1[0], + 1: fmt1[1], + 2: fmt1[2], + 3: concat_fmt(fmt1[3], fmt2), + length: 4, + tag: 6 + }; case 7 : - return [ - /* Int64 */7, - fmt1[1], - fmt1[2], - fmt1[3], - concat_fmt(fmt1[4], fmt2) - ]; + return /* Int64 */{ + 0: fmt1[0], + 1: fmt1[1], + 2: fmt1[2], + 3: concat_fmt(fmt1[3], fmt2), + length: 4, + tag: 7 + }; case 8 : - return [ - /* Float */8, - fmt1[1], - fmt1[2], - fmt1[3], - concat_fmt(fmt1[4], fmt2) - ]; + return /* Float */{ + 0: fmt1[0], + 1: fmt1[1], + 2: fmt1[2], + 3: concat_fmt(fmt1[3], fmt2), + length: 4, + tag: 8 + }; case 9 : - return [ - /* Bool */9, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Bool */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 9 + }; case 10 : - return [ - /* Flush */10, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Flush */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 10 + }; case 11 : - return [ - /* String_literal */11, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* String_literal */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 11 + }; case 12 : - return [ - /* Char_literal */12, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* Char_literal */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 12 + }; case 13 : - return [ - /* Format_arg */13, - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]; + return /* Format_arg */{ + 0: fmt1[0], + 1: fmt1[1], + 2: concat_fmt(fmt1[2], fmt2), + length: 3, + tag: 13 + }; case 14 : - return [ - /* Format_subst */14, - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]; + return /* Format_subst */{ + 0: fmt1[0], + 1: fmt1[1], + 2: concat_fmt(fmt1[2], fmt2), + length: 3, + tag: 14 + }; case 15 : - return [ - /* Alpha */15, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Alpha */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 15 + }; case 16 : - return [ - /* Theta */16, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Theta */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 16 + }; case 17 : - return [ - /* Formatting_lit */17, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* Formatting_lit */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 17 + }; case 18 : - return [ - /* Formatting_gen */18, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* Formatting_gen */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 18 + }; case 19 : - return [ - /* Reader */19, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Reader */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 19 + }; case 20 : - return [ - /* Scan_char_set */20, - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]; + return /* Scan_char_set */{ + 0: fmt1[0], + 1: fmt1[1], + 2: concat_fmt(fmt1[2], fmt2), + length: 3, + tag: 20 + }; case 21 : - return [ - /* Scan_get_counter */21, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* Scan_get_counter */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 21 + }; case 22 : - return [ - /* Scan_next_char */22, - concat_fmt(fmt1[1], fmt2) - ]; + return /* Scan_next_char */{ + 0: concat_fmt(fmt1[0], fmt2), + length: 1, + tag: 22 + }; case 23 : - return [ - /* Ignored_param */23, - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]; + return /* Ignored_param */{ + 0: fmt1[0], + 1: concat_fmt(fmt1[1], fmt2), + length: 2, + tag: 23 + }; case 24 : - return [ - /* Custom */24, - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]; + return /* Custom */{ + 0: fmt1[0], + 1: fmt1[1], + 2: concat_fmt(fmt1[2], fmt2), + length: 3, + tag: 24 + }; } } diff --git a/jscomp/stdlib/camlinternalLazy.js b/jscomp/stdlib/camlinternalLazy.js index c684b4f423..058090312e 100644 --- a/jscomp/stdlib/camlinternalLazy.js +++ b/jscomp/stdlib/camlinternalLazy.js @@ -2,15 +2,15 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var Obj = require("./obj"); var Caml_curry = require("../runtime/caml_curry"); -var Undefined = [ - 248, - "CamlinternalLazy.Undefined", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Undefined = { + 0: "CamlinternalLazy.Undefined", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function raise_undefined() { throw Undefined; @@ -22,7 +22,7 @@ function force_lazy_block(blk) { try { var result = Caml_curry.app1(closure, /* () */0); blk[0] = result; - Caml_obj_runtime.caml_obj_set_tag(blk, Obj.forward_tag); + blk.tag = Obj.forward_tag; return result; } catch (e){ @@ -38,12 +38,12 @@ function force_val_lazy_block(blk) { blk[0] = raise_undefined; var result = Caml_curry.app1(closure, /* () */0); blk[0] = result; - Caml_obj_runtime.caml_obj_set_tag(blk, Obj.forward_tag); + blk.tag = Obj.forward_tag; return result; } function force(lzv) { - var t = Caml_obj_runtime.caml_obj_tag(lzv); + var t = lzv.tag | 0; if (t === Obj.forward_tag) { return lzv[0]; } @@ -56,7 +56,7 @@ function force(lzv) { } function force_val(lzv) { - var t = Caml_obj_runtime.caml_obj_tag(lzv); + var t = lzv.tag | 0; if (t === Obj.forward_tag) { return lzv[0]; } diff --git a/jscomp/stdlib/camlinternalMod.js b/jscomp/stdlib/camlinternalMod.js index 07bc61eff4..18a6312dc9 100644 --- a/jscomp/stdlib/camlinternalMod.js +++ b/jscomp/stdlib/camlinternalMod.js @@ -2,132 +2,97 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); -var Obj = require("./obj"); +var Caml_obj = require("../runtime/caml_obj"); var CamlinternalOO = require("./camlinternalOO"); -var $$Array = require("./array"); -var Caml_curry = require("../runtime/caml_curry"); function init_mod(loc, shape) { - if (typeof shape === "number") { - switch (shape) { - case 0 : - return function () { - throw [ - 0, - Caml_builtin_exceptions.Undefined_recursive_module, - loc - ]; - }; - case 1 : - return [ - 246, - function () { - throw [ - 0, - Caml_builtin_exceptions.Undefined_recursive_module, - loc - ]; - } - ]; - case 2 : - return CamlinternalOO.dummy_class(loc); - + var undef_module = function () { + throw [ + Caml_builtin_exceptions.Undefined_recursive_module, + loc + ]; + }; + var loop = function (shape, struct_, idx) { + if (typeof shape === "number") { + switch (shape) { + case 0 : + case 1 : + struct_[idx] = undef_module; + return /* () */0; + case 2 : + struct_[idx] = CamlinternalOO.dummy_class(loc); + return /* () */0; + + } } - } - else if (shape[0]) { - return shape[1]; - } - else { - return $$Array.map(function (param) { - return init_mod(loc, param); - }, shape[1]); - } + else if (shape.tag) { + struct_[idx] = shape[0]; + return /* () */0; + } + else { + var comps = shape[0]; + var v = /* array */[]; + struct_[idx] = v; + var len = comps.length; + for(var i = 0 ,i_finish = len - 1; i<= i_finish; ++i){ + loop(comps[i], v, i); + } + return /* () */0; + } + }; + var res = /* array */[]; + loop(shape, res, 0); + return res[0]; } -function overwrite(o, n) { - if (o.length < n.length) { +function update_mod(shape, o, n) { + var aux = function (shape, o, n, parent, i) { + if (typeof shape === "number") { + switch (shape) { + case 0 : + parent[i] = n; + return /* () */0; + case 1 : + case 2 : + return Caml_obj.caml_update_dummy(o, n); + + } + } + else if (shape.tag) { + return /* () */0; + } + else { + var comps = shape[0]; + for(var i$1 = 0 ,i_finish = comps.length - 1; i$1<= i_finish; ++i$1){ + aux(comps[i$1], o[i$1], n[i$1], o, i$1); + } + return /* () */0; + } + }; + if (typeof shape === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalMod.ml", - 40, - 2 + 122, + 10 ] ]; } - for(var i = 0 ,i_finish = n.length - 1; i<= i_finish; ++i){ - o[i] = n[i]; - } - return /* () */0; -} - -function update_mod(shape, o, n) { - if (typeof shape === "number") { - switch (shape) { - case 0 : - if (Caml_obj_runtime.caml_obj_tag(n) === Obj.closure_tag && n.length <= o.length) { - overwrite(o, n); - return Caml_obj_runtime.caml_obj_truncate(o, n.length); - } - else { - return overwrite(o, function (x) { - return Caml_curry.app1(n, x); - }); - } - case 1 : - if (Caml_obj_runtime.caml_obj_tag(n) === Obj.lazy_tag) { - o[0] = n[0]; - return /* () */0; - } - else if (Caml_obj_runtime.caml_obj_tag(n) === Obj.forward_tag) { - Caml_obj_runtime.caml_obj_set_tag(o, Obj.forward_tag); - o[0] = n[0]; - return /* () */0; - } - else { - Caml_obj_runtime.caml_obj_set_tag(o, Obj.forward_tag); - o[0] = n; - return /* () */0; - } - case 2 : - if (!(Caml_obj_runtime.caml_obj_tag(n) === 0 && n.length === 4)) { - throw [ - 0, - Caml_builtin_exceptions.Assert_failure, - [ - 0, - "camlinternalMod.ml", - 63, - 6 - ] - ]; - } - return overwrite(o, n); - - } - } - else if (shape[0]) { - return /* () */0; + else if (shape.tag) { + throw [ + Caml_builtin_exceptions.Assert_failure, + [ + "camlinternalMod.ml", + 122, + 10 + ] + ]; } else { - var comps = shape[1]; - if (!(Caml_obj_runtime.caml_obj_tag(n) === 0 && n.length >= comps.length)) { - throw [ - 0, - Caml_builtin_exceptions.Assert_failure, - [ - 0, - "camlinternalMod.ml", - 66, - 6 - ] - ]; - } + var comps = shape[0]; for(var i = 0 ,i_finish = comps.length - 1; i<= i_finish; ++i){ - update_mod(comps[i], o[i], n[i]); + aux(comps[i], o[i], n[i], o, i); } return /* () */0; } diff --git a/jscomp/stdlib/camlinternalMod.ml b/jscomp/stdlib/camlinternalMod.ml index 5265a712e6..6c915233a9 100644 --- a/jscomp/stdlib/camlinternalMod.ml +++ b/jscomp/stdlib/camlinternalMod.ml @@ -18,53 +18,105 @@ type shape = | Module of shape array | Value of Obj.t -let rec init_mod loc shape = - match shape with - | Function -> - let pad1 = 1 and pad2 = 2 and pad3 = 3 and pad4 = 4 - and pad5 = 5 and pad6 = 6 and pad7 = 7 and pad8 = 8 in - Obj.repr(fun _ -> - ignore pad1; ignore pad2; ignore pad3; ignore pad4; - ignore pad5; ignore pad6; ignore pad7; ignore pad8; - raise (Undefined_recursive_module loc)) - | Lazy -> - Obj.repr (lazy (raise (Undefined_recursive_module loc))) - | Class -> - Obj.repr (CamlinternalOO.dummy_class loc) - | Module comps -> - Obj.repr (Array.map (init_mod loc) comps) - | Value v -> - v +(* let rec init_mod loc shape = *) +(* match shape with *) +(* | Function -> *) +(* let pad1 = 1 and pad2 = 2 and pad3 = 3 and pad4 = 4 *) +(* and pad5 = 5 and pad6 = 6 and pad7 = 7 and pad8 = 8 in *) +(* Obj.repr(fun _ -> *) +(* ignore pad1; ignore pad2; ignore pad3; ignore pad4; *) +(* ignore pad5; ignore pad6; ignore pad7; ignore pad8; *) +(* raise (Undefined_recursive_module loc)) *) +(* | Lazy -> *) +(* Obj.repr (lazy (raise (Undefined_recursive_module loc))) *) +(* | Class -> *) +(* Obj.repr (CamlinternalOO.dummy_class loc) *) +(* | Module comps -> *) +(* Obj.repr (Array.map (init_mod loc) comps) *) +(* | Value v -> *) +(* v *) -let overwrite o n = - assert (Obj.size o >= Obj.size n); - for i = 0 to Obj.size n - 1 do - Obj.set_field o i (Obj.field n i) - done +(* let overwrite o n = *) +(* assert (Obj.size o >= Obj.size n); *) +(* for i = 0 to Obj.size n - 1 do *) +(* Obj.set_field o i (Obj.field n i) *) +(* done *) -let rec update_mod shape o n = - match shape with - | Function -> - if Obj.tag n = Obj.closure_tag && Obj.size n <= Obj.size o - then begin overwrite o n; Obj.truncate o (Obj.size n) (* PR #4008 *) end - else overwrite o (Obj.repr (fun x -> (Obj.obj n : _ -> _) x)) - | Lazy -> - if Obj.tag n = Obj.lazy_tag then - Obj.set_field o 0 (Obj.field n 0) - else if Obj.tag n = Obj.forward_tag then begin (* PR#4316 *) - Obj.set_tag o Obj.forward_tag; - Obj.set_field o 0 (Obj.field n 0) - end else begin - (* forwarding pointer was shortcut by GC *) - Obj.set_tag o Obj.forward_tag; - Obj.set_field o 0 n - end - | Class -> - assert (Obj.tag n = 0 && Obj.size n = 4); - overwrite o n - | Module comps -> - assert (Obj.tag n = 0 && Obj.size n >= Array.length comps); - for i = 0 to Array.length comps - 1 do - update_mod comps.(i) (Obj.field o i) (Obj.field n i) +(* let rec update_mod shape o n = *) +(* match shape with *) +(* | Function -> *) +(* if Obj.tag n = Obj.closure_tag && Obj.size n <= Obj.size o *) +(* then begin overwrite o n; Obj.truncate o (Obj.size n) (\* PR #4008 *\) end *) +(* else overwrite o (Obj.repr (fun x -> (Obj.obj n : _ -> _) x)) *) +(* | Lazy -> *) +(* if Obj.tag n = Obj.lazy_tag then *) +(* Obj.set_field o 0 (Obj.field n 0) *) +(* else if Obj.tag n = Obj.forward_tag then begin (\* PR#4316 *\) *) +(* Obj.set_tag o Obj.forward_tag; *) +(* Obj.set_field o 0 (Obj.field n 0) *) +(* end else begin *) +(* (\* forwarding pointer was shortcut by GC *\) *) +(* Obj.set_tag o Obj.forward_tag; *) +(* Obj.set_field o 0 n *) +(* end *) +(* | Class -> *) +(* assert (Obj.tag n = 0 && Obj.size n = 4); *) +(* overwrite o n *) +(* | Module comps -> *) +(* assert (Obj.tag n = 0 && Obj.size n >= Array.length comps); *) +(* for i = 0 to Array.length comps - 1 do *) +(* update_mod comps.(i) (Obj.field o i) (Obj.field n i) *) +(* done *) +(* | Value v -> () (\* the value is already there *\) *) + + +(** Note that we have to provide a drop in replacement, since compiler internally will + spit out ("CamlinternalMod".[init_mod|update_mod] unless we intercept it + in the lambda layer + *) +let init_mod (loc : string * int * int) (shape : shape) = + let undef_module _ = raise (Undefined_recursive_module loc) in + let rec loop (shape : shape) (struct_ : Obj.t array) idx = + match shape with + | Function -> struct_.(idx)<-(Obj.magic undef_module) + | Lazy -> struct_.(idx)<- (Obj.magic (lazy undef_module)) + | Class -> struct_.(idx)<- (Obj.magic (CamlinternalOO.dummy_class loc)) + | Module comps + -> + let v = (Obj.magic [||]) in + struct_.(idx)<- v ; + let len = Array.length comps in + for i = 0 to len - 1 do + loop comps.(i) v i + done + | Value v -> + struct_.(idx) <- v in + let res = (Obj.magic [||] : Obj.t array) in + loop shape res 0 ; + res.(0) + +external caml_update_dummy : Obj.t -> Obj.t -> unit = "caml_update_dummy" +(* Note the [shape] passed between [init_mod] and [update_mod] is always the same + and we assume [module] is encoded as an array + *) +let update_mod (shape : shape) (o : Obj.t) (n : Obj.t) : unit = + let rec aux (shape : shape) o n parent i = + match shape with + | Function + -> Obj.set_field parent i n + + | Lazy + | Class -> + caml_update_dummy o n + | Module comps + -> + for i = 0 to Array.length comps - 1 do + aux comps.(i) (Obj.field o i) (Obj.field n i) o i done - | Value v -> () (* the value is already there *) + | Value _ -> () in + match shape with + | Module comps -> + for i = 0 to Array.length comps - 1 do + aux comps.(i) (Obj.field o i) (Obj.field n i) o i + done + | _ -> assert false diff --git a/jscomp/stdlib/camlinternalOO.js b/jscomp/stdlib/camlinternalOO.js index 32b4266d4e..24aa12f056 100644 --- a/jscomp/stdlib/camlinternalOO.js +++ b/jscomp/stdlib/camlinternalOO.js @@ -2,11 +2,10 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); +var Caml_obj = require("../runtime/caml_obj"); var Obj = require("./obj"); var Caml_oo = require("../runtime/caml_oo"); var Sys = require("./sys"); -var Caml_primitive = require("../runtime/caml_primitive"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("./array"); var Caml_curry = require("../runtime/caml_curry"); @@ -14,11 +13,10 @@ var Caml_string = require("../runtime/caml_string"); var List = require("./list"); function copy(o) { - return Caml_builtin_exceptions.caml_set_oo_id(Caml_obj_runtime.caml_obj_dup(o)); + return Caml_builtin_exceptions.caml_set_oo_id(Caml_obj.caml_obj_dup(o)); } -var params = [ - /* record */0, +var params = /* record */[ /* true */1, /* true */1, /* true */1, @@ -42,7 +40,7 @@ function public_method_label(s) { function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -52,34 +50,34 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -87,7 +85,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -95,19 +92,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -115,30 +111,30 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -149,25 +145,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -175,14 +173,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -196,8 +194,8 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold(f, m[0], accu)); + _m = m[3]; continue ; } @@ -209,7 +207,7 @@ function fold(f, _m, _accu) { function height$1(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -219,34 +217,34 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal$1(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } else if (lr) { - return create$1(create$1(ll, lv, ld, lr[1]), lr[2], lr[3], create$1(lr[4], x, d, r)); + return create$1(create$1(ll, lv, ld, lr[0]), lr[1], lr[2], create$1(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -254,7 +252,6 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -262,19 +259,18 @@ function bal$1(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create$1(create$1(l, x, d, rl[1]), rl[2], rl[3], create$1(rl[4], rv, rd, rr)); + return create$1(create$1(l, x, d, rl[0]), rl[1], rl[2], create$1(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -282,30 +278,30 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add$1(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -316,31 +312,33 @@ function add$1(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } function height$2(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -350,34 +348,34 @@ function height$2(param) { function create$2(l, x, d, r) { var hl = height$2(l); var hr = height$2(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal$2(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height$2(ll) >= height$2(lr)) { return create$2(ll, lv, ld, create$2(lr, x, d, r)); } else if (lr) { - return create$2(create$2(ll, lv, ld, lr[1]), lr[2], lr[3], create$2(lr[4], x, d, r)); + return create$2(create$2(ll, lv, ld, lr[0]), lr[1], lr[2], create$2(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -385,7 +383,6 @@ function bal$2(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -393,19 +390,18 @@ function bal$2(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height$2(rr) >= height$2(rl)) { return create$2(create$2(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create$2(create$2(l, x, d, rl[1]), rl[2], rl[3], create$2(rl[4], rv, rd, rr)); + return create$2(create$2(l, x, d, rl[0]), rl[1], rl[2], create$2(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -413,31 +409,31 @@ function bal$2(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add$2(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal$2(add$2(x, data, l), v, d, r); @@ -447,25 +443,27 @@ function add$2(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -473,14 +471,14 @@ function find$1(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -489,8 +487,7 @@ function find$1(x, _param) { }; } -var dummy_table = [ - /* record */0, +var dummy_table = /* record */[ 0, /* array */[/* () */0], /* Empty */0, @@ -501,12 +498,9 @@ var dummy_table = [ /* [] */0 ]; -var table_count = [ - 0, - 0 -]; +var table_count = [0]; -var dummy_met = [0]; +var dummy_met = []; function fit_size(n) { if (n <= 2) { @@ -518,7 +512,7 @@ function fit_size(n) { } function new_table(pub_labels) { - ++ table_count[1]; + ++ table_count[0]; var len = pub_labels.length; var methods = Caml_array.caml_make_vect(len * 2 + 2, dummy_met); methods[0] = len; @@ -526,8 +520,7 @@ function new_table(pub_labels) { for(var i = 0 ,i_finish = len - 1; i<= i_finish; ++i){ methods[i * 2 + 3] = pub_labels[i]; } - return [ - /* record */0, + return /* record */[ 2, methods, /* Empty */0, @@ -540,11 +533,11 @@ function new_table(pub_labels) { } function resize(array, new_size) { - var old_size = array[2].length; + var old_size = array[1].length; if (new_size > old_size) { var new_buck = Caml_array.caml_make_vect(new_size, dummy_met); - $$Array.blit(array[2], 0, new_buck, 0, old_size); - array[2] = new_buck; + $$Array.blit(array[1], 0, new_buck, 0, old_size); + array[1] = new_buck; return /* () */0; } else { @@ -552,18 +545,12 @@ function resize(array, new_size) { } } -var method_count = [ - 0, - 0 -]; +var method_count = [0]; -var inst_var_count = [ - 0, - 0 -]; +var inst_var_count = [0]; function new_method(table) { - var index = table[2].length; + var index = table[1].length; resize(table, index + 1); return index; } @@ -571,18 +558,18 @@ function new_method(table) { function get_method_label(table, name) { try { var x = name; - var _param = table[3]; + var _param = table[2]; while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -593,8 +580,8 @@ function get_method_label(table, name) { catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { var label = new_method(table); - table[3] = add$1(name, label, table[3]); - table[4] = add$2(label, /* true */1, table[4]); + table[2] = add$1(name, label, table[2]); + table[3] = add$2(label, /* true */1, table[3]); return label; } else { @@ -610,24 +597,22 @@ function get_method_labels(table, names) { } function set_method(table, label, element) { - ++ method_count[1]; - if (find$1(label, table[4])) { + ++ method_count[0]; + if (find$1(label, table[3])) { var array = table; var label$1 = label; var element$1 = element; resize(array, label$1 + 1); - array[2][label$1] = element$1; + array[1][label$1] = element$1; return /* () */0; } else { - table[6] = [ - /* :: */0, - [ - /* tuple */0, + table[5] = /* :: */[ + /* tuple */[ label, element ], - table[6] + table[5] ]; return /* () */0; } @@ -635,11 +620,11 @@ function set_method(table, label, element) { function get_method(table, label) { try { - return List.assoc(label, table[6]); + return List.assoc(label, table[5]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - return table[2][label]; + return table[1][label]; } else { throw exn; @@ -666,40 +651,32 @@ function narrow(table, vars, virt_meths, concr_meths) { var concr_meth_labs = List.map(function (param) { return get_method_label(table, param); }, concr_meths$1); - table[5] = [ - /* :: */0, - [ - /* tuple */0, + table[4] = /* :: */[ + /* tuple */[ + table[2], table[3], - table[4], + table[5], table[6], - table[7], virt_meth_labs, vars$1 ], - table[5] + table[4] ]; - table[7] = fold(function (lab, info, tvars) { + table[6] = fold(function (lab, info, tvars) { if (List.mem(lab, vars$1)) { return add(lab, info, tvars); } else { return tvars; } - }, table[7], /* Empty */0); - var by_name = [ - 0, - /* Empty */0 - ]; - var by_label = [ - 0, - /* Empty */0 - ]; + }, table[6], /* Empty */0); + var by_name = [/* Empty */0]; + var by_label = [/* Empty */0]; List.iter2(function (met, label) { - by_name[1] = add$1(met, label, by_name[1]); + by_name[0] = add$1(met, label, by_name[0]); var $js; try { - $js = find$1(label, table[4]); + $js = find$1(label, table[3]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { @@ -709,70 +686,68 @@ function narrow(table, vars, virt_meths, concr_meths) { throw exn; } } - by_label[1] = add$2(label, $js, by_label[1]); + by_label[0] = add$2(label, $js, by_label[0]); return /* () */0; }, concr_meths$1, concr_meth_labs); List.iter2(function (met, label) { - by_name[1] = add$1(met, label, by_name[1]); - by_label[1] = add$2(label, /* false */0, by_label[1]); + by_name[0] = add$1(met, label, by_name[0]); + by_label[0] = add$2(label, /* false */0, by_label[0]); return /* () */0; }, virt_meths$1, virt_meth_labs); - table[3] = by_name[1]; - table[4] = by_label[1]; - table[6] = List.fold_right(function (met, hm) { - if (List.mem(met[1], virt_meth_labs)) { + table[2] = by_name[0]; + table[3] = by_label[0]; + table[5] = List.fold_right(function (met, hm) { + if (List.mem(met[0], virt_meth_labs)) { return hm; } else { - return [ - /* :: */0, + return /* :: */[ met, hm ]; } - }, table[6], /* [] */0); + }, table[5], /* [] */0); return /* () */0; } function widen(table) { - var match = List.hd(table[5]); - var virt_meths = match[5]; - table[5] = List.tl(table[5]); - table[7] = List.fold_left(function (s, v) { - return add(v, find(v, table[7]), s); - }, match[4], match[6]); + var match = List.hd(table[4]); + var virt_meths = match[4]; + table[4] = List.tl(table[4]); + table[6] = List.fold_left(function (s, v) { + return add(v, find(v, table[6]), s); + }, match[3], match[5]); + table[2] = match[0]; table[3] = match[1]; - table[4] = match[2]; - table[6] = List.fold_right(function (met, hm) { - if (List.mem(met[1], virt_meths)) { + table[5] = List.fold_right(function (met, hm) { + if (List.mem(met[0], virt_meths)) { return hm; } else { - return [ - /* :: */0, + return /* :: */[ met, hm ]; } - }, table[6], match[3]); + }, table[5], match[2]); return /* () */0; } function new_slot(table) { - var index = table[1]; - table[1] = index + 1; + var index = table[0]; + table[0] = index + 1; return index; } function new_variable(table, name) { try { - return find(name, table[7]); + return find(name, table[6]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { var index = new_slot(table); if (name !== "") { - table[7] = add(name, index, table[7]); + table[6] = add(name, index, table[6]); } return index; } @@ -783,7 +758,7 @@ function new_variable(table, name) { } function to_array(arr) { - if (Caml_primitive.caml_equal(arr, 0)) { + if (Caml_obj.caml_equal(arr, 0)) { return /* array */[]; } else { @@ -807,15 +782,13 @@ function new_methods_variables(table, meths, vals) { function get_variable(table, name) { try { - return find(name, table[7]); + return find(name, table[6]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "camlinternalOO.ml", 280, 50 @@ -835,10 +808,9 @@ function get_variables(table, names) { } function add_initializer(table, f) { - table[8] = [ - /* :: */0, + table[7] = /* :: */[ f, - table[8] + table[7] ]; return /* () */0; } @@ -849,8 +821,8 @@ function create_table(public_methods) { var table = new_table(tags); $$Array.iteri(function (i, met) { var lab = i * 2 + 2; - table[3] = add$1(met, lab, table[3]); - table[4] = add$2(lab, /* true */1, table[4]); + table[2] = add$1(met, lab, table[2]); + table[3] = add$2(lab, /* true */1, table[3]); return /* () */0; }, public_methods); return table; @@ -861,26 +833,23 @@ function create_table(public_methods) { } function init_class(table) { - inst_var_count[1] = inst_var_count[1] + table[1] - 1; - table[8] = List.rev(table[8]); - return resize(table, 3 + (table[2][1] * 16 / Sys.word_size | 0)); + inst_var_count[0] = inst_var_count[0] + table[0] - 1; + table[7] = List.rev(table[7]); + return resize(table, 3 + (table[1][1] * 16 / Sys.word_size | 0)); } function inherits(cla, vals, virt_meths, concr_meths, param, top) { - var $$super = param[2]; + var $$super = param[1]; narrow(cla, vals, virt_meths, concr_meths); - var init = top ? Caml_curry.app2($$super, cla, param[4]) : Caml_curry.app1($$super, cla); + var init = top ? Caml_curry.app2($$super, cla, param[3]) : Caml_curry.app1($$super, cla); widen(cla); - return Caml_array.caml_array_concat([ - /* :: */0, + return Caml_array.caml_array_concat(/* :: */[ /* array */[init], - [ - /* :: */0, + /* :: */[ $$Array.map(function (param) { return get_variable(cla, param); }, to_array(vals)), - [ - /* :: */0, + /* :: */[ $$Array.map(function (nm) { return get_method(cla, get_method_label(cla, nm)); }, to_array(concr_meths)), @@ -894,8 +863,7 @@ function make_class(pub_meths, class_init) { var table = create_table(pub_meths); var env_init = Caml_curry.app1(class_init, table); init_class(table); - return [ - /* tuple */0, + return /* tuple */[ Caml_curry.app1(env_init, 0), class_init, env_init, @@ -907,21 +875,19 @@ function make_class_store(pub_meths, class_init, init_table) { var table = create_table(pub_meths); var env_init = Caml_curry.app1(class_init, table); init_class(table); - init_table[2] = class_init; - init_table[1] = env_init; + init_table[1] = class_init; + init_table[0] = env_init; return /* () */0; } function dummy_class(loc) { var undef = function () { throw [ - 0, Caml_builtin_exceptions.Undefined_recursive_module, loc ]; }; - return [ - /* tuple */0, + return /* tuple */[ undef, undef, undef, @@ -930,8 +896,11 @@ function dummy_class(loc) { } function create_object(table) { - var obj = Object.defineProperty(Caml_obj_runtime.caml_obj_block(Obj.object_tag, table[1]), "##ml",{"value" : true, "writable" : false}); - obj[1] = table[2]; + var obj = { + length: table[0], + tag: Obj.object_tag + }; + obj[0] = table[1]; return Caml_builtin_exceptions.caml_set_oo_id(obj); } @@ -940,8 +909,11 @@ function create_object_opt(obj_0, table) { return obj_0; } else { - var obj = Object.defineProperty(Caml_obj_runtime.caml_obj_block(Obj.object_tag, table[1]), "##ml",{"value" : true, "writable" : false}); - obj[1] = table[2]; + var obj = { + length: table[0], + tag: Obj.object_tag + }; + obj[0] = table[1]; return Caml_builtin_exceptions.caml_set_oo_id(obj); } } @@ -950,8 +922,8 @@ function iter_f(obj, _param) { while(true) { var param = _param; if (param) { - Caml_curry.app1(param[1], obj); - _param = param[2]; + Caml_curry.app1(param[0], obj); + _param = param[1]; continue ; } @@ -962,7 +934,7 @@ function iter_f(obj, _param) { } function run_initializers(obj, table) { - var inits = table[8]; + var inits = table[7]; if (inits !== /* [] */0) { return iter_f(obj, inits); } @@ -976,7 +948,7 @@ function run_initializers_opt(obj_0, obj, table) { return obj; } else { - var inits = table[8]; + var inits = table[7]; if (inits !== /* [] */0) { iter_f(obj, inits); } @@ -996,22 +968,22 @@ function create_object_and_run_initializers(obj_0, table) { } function build_path(n, keys, tables) { - var res = [ - /* record */0, + var res = /* record */[ 0, /* Empty */0, /* Empty */0 ]; var r = res; for(var i = 0; i<= n; ++i){ - r = [ - /* Cons */0, - keys[i], - r, - /* Empty */0 - ]; + r = /* Cons */{ + 0: keys[i], + 1: r, + 2: /* Empty */0, + length: 3, + tag: 0 + }; } - tables[2] = r; + tables[1] = r; return res; } @@ -1024,22 +996,23 @@ function lookup_keys(i, keys, tables) { var _tables = tables; while(true) { var tables$1 = _tables; - if (tables$1[1] === key) { - return lookup_keys(i - 1, keys, tables$1[2]); + if (tables$1[0] === key) { + return lookup_keys(i - 1, keys, tables$1[1]); } - else if (tables$1[3] !== /* Empty */0) { - _tables = tables$1[3]; + else if (tables$1[2] !== /* Empty */0) { + _tables = tables$1[2]; continue ; } else { - var next = [ - /* Cons */0, - key, - /* Empty */0, - /* Empty */0 - ]; - tables$1[3] = next; + var next = /* Cons */{ + 0: key, + 1: /* Empty */0, + 2: /* Empty */0, + length: 3, + tag: 0 + }; + tables$1[2] = next; return build_path(i - 1, keys, next); } }; @@ -1047,8 +1020,8 @@ function lookup_keys(i, keys, tables) { } function lookup_tables(root, keys) { - if (root[2] !== /* Empty */0) { - return lookup_keys(keys.length - 1, keys, root[2]); + if (root[1] !== /* Empty */0) { + return lookup_keys(keys.length - 1, keys, root[1]); } else { return build_path(keys.length - 1, keys, root); @@ -1057,15 +1030,15 @@ function lookup_tables(root, keys) { function new_cache(table) { var n = new_method(table); - var n$1 = n % 2 === 0 || n > 2 + (table[2][1] * 16 / Sys.word_size | 0) ? n : new_method(table); - table[2][n$1] = 0; + var n$1 = n % 2 === 0 || n > 2 + (table[1][1] * 16 / Sys.word_size | 0) ? n : new_method(table); + table[1][n$1] = 0; return n$1; } function method_impl(table, i, arr) { var next = function () { - ++ i[1]; - return arr[i[1]]; + ++ i[0]; + return arr[i[0]]; }; var clo = next(/* () */0); if (typeof clo === "number") { @@ -1091,7 +1064,7 @@ function method_impl(table, i, arr) { case 3 : var n$3 = next(/* () */0); return function (obj) { - return Caml_curry.app1(obj[1][n$3], obj); + return Caml_curry.app1(obj[0][n$3], obj); }; case 4 : var n$4 = next(/* () */0); @@ -1127,7 +1100,7 @@ function method_impl(table, i, arr) { var f$5 = f$4; var n$9 = n$8; return function (obj) { - return Caml_curry.app1(f$5, Caml_curry.app1(obj[1][n$9], obj)); + return Caml_curry.app1(f$5, Caml_curry.app1(obj[0][n$9], obj)); }; case 9 : var f$6 = next(/* () */0); @@ -1166,7 +1139,7 @@ function method_impl(table, i, arr) { var x$8 = x$7; var n$15 = n$14; return function (obj) { - return Caml_curry.app2(f$12, x$8, Caml_curry.app1(obj[1][n$15], obj)); + return Caml_curry.app2(f$12, x$8, Caml_curry.app1(obj[0][n$15], obj)); }; case 13 : var f$13 = next(/* () */0); @@ -1198,7 +1171,7 @@ function method_impl(table, i, arr) { var n$21 = n$20; var x$14 = x$13; return function (obj) { - return Caml_curry.app2(f$18, Caml_curry.app1(obj[1][n$21], obj), x$14); + return Caml_curry.app2(f$18, Caml_curry.app1(obj[0][n$21], obj), x$14); }; case 16 : var n$22 = next(/* () */0); @@ -1206,7 +1179,7 @@ function method_impl(table, i, arr) { var n$23 = n$22; var x$16 = x$15; return function (obj) { - return Caml_curry.app2(obj[1][n$23], obj, x$16); + return Caml_curry.app2(obj[0][n$23], obj, x$16); }; case 17 : var n$24 = next(/* () */0); @@ -1214,7 +1187,7 @@ function method_impl(table, i, arr) { var n$25 = n$24; var m$1 = m; return function (obj) { - return Caml_curry.app2(obj[1][n$25], obj, obj[m$1]); + return Caml_curry.app2(obj[0][n$25], obj, obj[m$1]); }; case 18 : var n$26 = next(/* () */0); @@ -1224,7 +1197,7 @@ function method_impl(table, i, arr) { var e$9 = e$8; var m$3 = m$2; return function (obj) { - return Caml_curry.app2(obj[1][n$27], obj, obj[e$9][m$3]); + return Caml_curry.app2(obj[0][n$27], obj, obj[e$9][m$3]); }; case 19 : var n$28 = next(/* () */0); @@ -1232,7 +1205,7 @@ function method_impl(table, i, arr) { var n$29 = n$28; var m$5 = m$4; return function (obj) { - return Caml_curry.app2(obj[1][n$29], obj, Caml_curry.app1(obj[1][m$5], obj)); + return Caml_curry.app2(obj[0][n$29], obj, Caml_curry.app1(obj[0][m$5], obj)); }; case 20 : var m$6 = next(/* () */0); @@ -1270,7 +1243,7 @@ function method_impl(table, i, arr) { var n$35 = n$34; new_cache(table); return function (obj) { - return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, Caml_curry.app1(obj[1][n$35], obj), m$13, 4), Caml_curry.app1(obj[1][n$35], obj)); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, Caml_curry.app1(obj[0][n$35], obj), m$13, 4), Caml_curry.app1(obj[0][n$35], obj)); }; } @@ -1282,25 +1255,21 @@ function method_impl(table, i, arr) { function set_methods(table, methods) { var len = methods.length; - var i = [ - 0, - 0 - ]; - while(i[1] < len) { - var label = methods[i[1]]; + var i = [0]; + while(i[0] < len) { + var label = methods[i[0]]; var clo = method_impl(table, i, methods); set_method(table, label, clo); - ++ i[1]; + ++ i[0]; }; return /* () */0; } function stats() { - return [ - /* record */0, - table_count[1], - method_count[1], - inst_var_count[1] + return /* record */[ + table_count[0], + method_count[0], + inst_var_count[0] ]; } diff --git a/jscomp/stdlib/camlinternalOO.ml b/jscomp/stdlib/camlinternalOO.ml index ba874cf039..85f7704e9d 100644 --- a/jscomp/stdlib/camlinternalOO.ml +++ b/jscomp/stdlib/camlinternalOO.ml @@ -351,7 +351,7 @@ let create_object table = (* XXX Appel de [obj_block] *) let obj = mark_ocaml_object @@ Obj.new_block Obj.object_tag table.size in (* XXX Appel de [caml_modify] *) - Obj.set_field obj 1 (Obj.repr table.methods); (** Temporary fix -- it's a block *) + Obj.set_field obj 0 (Obj.repr table.methods); Obj.obj (set_id obj) let create_object_opt obj_0 table = @@ -359,7 +359,7 @@ let create_object_opt obj_0 table = (* XXX Appel de [obj_block] *) let obj = mark_ocaml_object @@ Obj.new_block Obj.object_tag table.size in (* XXX Appel de [caml_modify] *) - Obj.set_field obj 1 (Obj.repr table.methods); (** Temporary fix --*) + Obj.set_field obj 0 (Obj.repr table.methods); Obj.obj (set_id obj) end diff --git a/jscomp/stdlib/char.js b/jscomp/stdlib/char.js index a5d8cb8135..1bc7b04f34 100644 --- a/jscomp/stdlib/char.js +++ b/jscomp/stdlib/char.js @@ -7,7 +7,6 @@ var Caml_string = require("../runtime/caml_string"); function chr(n) { if (n < 0 || n > 255) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Char.chr" ]; @@ -59,11 +58,11 @@ function escaped(c) { } if (exit === 1) { if (Caml_string.caml_is_printable(c)) { - return Caml_string.caml_string_of_char_array(/* array */[c]); + return Caml_string.caml_string_of_char_array(/* int array */[c]); } else { var n = c; - return Caml_string.caml_string_of_char_array(/* array */[ + return Caml_string.caml_string_of_char_array(/* int array */[ /* "\\" */92, 48 + (n / 100 | 0), 48 + (n / 10 | 0) % 10, diff --git a/jscomp/stdlib/complex.js b/jscomp/stdlib/complex.js index ad252be295..4c546237bb 100644 --- a/jscomp/stdlib/complex.js +++ b/jscomp/stdlib/complex.js @@ -8,35 +8,35 @@ var one = /* float array */[ ]; function add(x, y) { - return /* array */[ + return /* float array */[ x[0] + y[0], x[1] + y[1] ]; } function sub(x, y) { - return /* array */[ + return /* float array */[ x[0] - y[0], x[1] - y[1] ]; } function neg(x) { - return /* array */[ + return /* float array */[ -x[0], -x[1] ]; } function conj(x) { - return /* array */[ + return /* float array */[ x[0], -x[1] ]; } function mul(x, y) { - return /* array */[ + return /* float array */[ x[0] * y[0] - x[1] * y[1], x[0] * y[1] + x[1] * y[0] ]; @@ -46,7 +46,7 @@ function div(x, y) { if (Math.abs(y[0]) >= Math.abs(y[1])) { var r = y[1] / y[0]; var d = y[0] + r * y[1]; - return /* array */[ + return /* float array */[ (x[0] + r * x[1]) / d, (x[1] - r * x[0]) / d ]; @@ -54,7 +54,7 @@ function div(x, y) { else { var r$1 = y[0] / y[1]; var d$1 = y[1] + r$1 * y[0]; - return /* array */[ + return /* float array */[ (r$1 * x[0] + x[1]) / d$1, (r$1 * x[1] - x[0]) / d$1 ]; @@ -93,7 +93,7 @@ function arg(x) { } function polar(n, a) { - return /* array */[ + return /* float array */[ Math.cos(a) * n, Math.sin(a) * n ]; @@ -119,13 +119,13 @@ function sqrt(x) { w = Math.sqrt(i) * Math.sqrt(0.5 * (q$1 + Math.sqrt(1.0 + q$1 * q$1))); } if (x[0] >= 0.0) { - return /* array */[ + return /* float array */[ w, 0.5 * x[1] / w ]; } else { - return /* array */[ + return /* float array */[ 0.5 * i / w, x[1] >= 0.0 ? w : -w ]; @@ -135,14 +135,14 @@ function sqrt(x) { function exp(x) { var e = Math.exp(x[0]); - return /* array */[ + return /* float array */[ e * Math.cos(x[1]), e * Math.sin(x[1]) ]; } function log(x) { - return /* array */[ + return /* float array */[ Math.log(norm(x)), Math.atan2(x[1], x[0]) ]; diff --git a/jscomp/stdlib/digest.js b/jscomp/stdlib/digest.js index aa12756735..404906d3dd 100644 --- a/jscomp/stdlib/digest.js +++ b/jscomp/stdlib/digest.js @@ -19,7 +19,6 @@ function bytes(b) { function substring(str, ofs, len) { if (ofs < 0 || len < 0 || ofs > str.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Digest.substring" ]; @@ -79,7 +78,6 @@ function to_hex(d) { function from_hex(s) { if (s.length !== 32) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Digest.from_hex" ]; @@ -89,7 +87,6 @@ function from_hex(s) { if (c >= 97) { if (c >= 103) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Digest.from_hex" ]; @@ -100,7 +97,6 @@ function from_hex(s) { } else if (c >= 71) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Digest.from_hex" ]; @@ -111,7 +107,6 @@ function from_hex(s) { } else if (c > 57 || c < 48) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Digest.from_hex" ]; diff --git a/jscomp/stdlib/filename.js b/jscomp/stdlib/filename.js index 0045cc6f09..0e56669d9d 100644 --- a/jscomp/stdlib/filename.js +++ b/jscomp/stdlib/filename.js @@ -2,7 +2,6 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var CamlinternalLazy = require("./camlinternalLazy"); var Caml_sys = require("../runtime/caml_sys"); var Pervasives = require("./pervasives"); @@ -214,7 +213,6 @@ function chop_suffix(name, suff) { var n = name.length - suff.length; if (n < 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Filename.chop_suffix" ]; @@ -230,7 +228,6 @@ function chop_extension(name) { var i = _i; if (i < 0 || Caml_curry.app2(is_dir_sep$1, name, i)) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Filename.chop_extension" ]; @@ -246,72 +243,72 @@ function chop_extension(name) { }; } -var prng = [ - 246, - function () { - return Caml_curry.app1(Random.State[2], /* () */0); - } -]; +var prng = { + 0: function () { + return Caml_curry.app1(Random.State[1], /* () */0); + }, + length: 1, + tag: 246 +}; function temp_file_name(temp_dir, prefix, suffix) { - var tag = Caml_obj_runtime.caml_obj_tag(prng); - var rnd = Caml_curry.app1(Random.State[4], tag === 250 ? prng[1] : ( + var tag = prng.tag | 0; + var rnd = Caml_curry.app1(Random.State[3], tag === 250 ? prng[0] : ( tag === 246 ? CamlinternalLazy.force_lazy_block(prng) : prng )) & 16777215; - return concat(temp_dir, Caml_curry.app3(Printf.sprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* Int */4, - /* Int_x */6, - [ - /* Lit_padding */0, - /* Zeros */2, - 6 - ], - /* No_precision */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ], - "%s%06x%s" - ]), prefix, rnd, suffix)); + return concat(temp_dir, Caml_curry.app3(Printf.sprintf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* Int */{ + 0: /* Int_x */6, + 1: /* Lit_padding */{ + 0: /* Zeros */2, + 1: 6, + length: 2, + tag: 0 + }, + 2: /* No_precision */0, + 3: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 2 + }, + 1: "%s%06x%s", + length: 2, + tag: 0 + }), prefix, rnd, suffix)); } -var current_temp_dir_name = [ - 0, - temp_dir_name$2 -]; +var current_temp_dir_name = [temp_dir_name$2]; function set_temp_dir_name(s) { - current_temp_dir_name[1] = s; + current_temp_dir_name[0] = s; return /* () */0; } function get_temp_dir_name() { - return current_temp_dir_name[1]; + return current_temp_dir_name[0]; } function temp_file($staropt$star, prefix, suffix) { - var temp_dir = $staropt$star ? $staropt$star[1] : current_temp_dir_name[1]; + var temp_dir = $staropt$star ? $staropt$star[0] : current_temp_dir_name[0]; var _counter = 0; while(true) { var counter = _counter; var name = temp_file_name(temp_dir, prefix, suffix); try { - Caml_primitive.caml_sys_close(Caml_primitive.caml_sys_open(name, [ - /* :: */0, + Caml_primitive.caml_sys_close(Caml_primitive.caml_sys_open(name, /* :: */[ /* Open_wronly */1, - [ - /* :: */0, + /* :: */[ /* Open_creat */3, - [ - /* :: */0, + /* :: */[ /* Open_excl */5, /* [] */0 ] @@ -320,7 +317,7 @@ function temp_file($staropt$star, prefix, suffix) { return name; } catch (e){ - if (e[1] === Caml_builtin_exceptions.Sys_error) { + if (e[0] === Caml_builtin_exceptions.Sys_error) { if (counter >= 1000) { throw e; } @@ -338,28 +335,23 @@ function temp_file($staropt$star, prefix, suffix) { } function open_temp_file($staropt$star, $staropt$star$1, prefix, suffix) { - var mode = $staropt$star ? $staropt$star[1] : [ - /* :: */0, + var mode = $staropt$star ? $staropt$star[0] : /* :: */[ /* Open_text */7, /* [] */0 ]; - var temp_dir = $staropt$star$1 ? $staropt$star$1[1] : current_temp_dir_name[1]; + var temp_dir = $staropt$star$1 ? $staropt$star$1[0] : current_temp_dir_name[0]; var _counter = 0; while(true) { var counter = _counter; var name = temp_file_name(temp_dir, prefix, suffix); try { - return [ - /* tuple */0, + return /* tuple */[ name, - Pervasives.open_out_gen([ - /* :: */0, + Pervasives.open_out_gen(/* :: */[ /* Open_wronly */1, - [ - /* :: */0, + /* :: */[ /* Open_creat */3, - [ - /* :: */0, + /* :: */[ /* Open_excl */5, mode ] @@ -368,7 +360,7 @@ function open_temp_file($staropt$star, $staropt$star$1, prefix, suffix) { ]; } catch (e){ - if (e[1] === Caml_builtin_exceptions.Sys_error) { + if (e[0] === Caml_builtin_exceptions.Sys_error) { if (counter >= 1000) { throw e; } diff --git a/jscomp/stdlib/format.js b/jscomp/stdlib/format.js index b9a9fb789e..e09a79086b 100644 --- a/jscomp/stdlib/format.js +++ b/jscomp/stdlib/format.js @@ -2,47 +2,47 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Caml_io = require("../runtime/caml_io"); var Pervasives = require("./pervasives"); -var Caml_primitive = require("../runtime/caml_primitive"); var Buffer = require("./buffer"); var Caml_curry = require("../runtime/caml_curry"); var $$String = require("./string"); var CamlinternalFormat = require("./camlinternalFormat"); function add_queue(x, q) { - var c_001 = [ - /* record */0, - x, - /* Nil */0 - ]; - var c = [ - /* Cons */0, - c_001 - ]; - var match = q[1]; + var c = /* Cons */{ + 0: /* record */[ + x, + /* Nil */0 + ], + length: 1, + tag: 0 + }; + var match = q[0]; if (match) { - q[1] = c; - match[1][2] = c; + q[0] = c; + match[0][1] = c; return /* () */0; } else { + q[0] = c; q[1] = c; - q[2] = c; return /* () */0; } } -var Empty_queue = [ - 248, - "Format.Empty_queue", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Empty_queue = { + 0: "Format.Empty_queue", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function peek_queue(param) { - var match = param[2]; + var match = param[1]; if (match) { - return match[1][1]; + return match[0][0]; } else { throw Empty_queue; @@ -50,14 +50,14 @@ function peek_queue(param) { } function take_queue(q) { - var match = q[2]; + var match = q[1]; if (match) { - var match$1 = match[1]; - var x = match$1[1]; - var tl = match$1[2]; - q[2] = tl; + var match$1 = match[0]; + var x = match$1[0]; + var tl = match$1[1]; + q[1] = tl; if (!tl) { - q[1] = /* Nil */0; + q[0] = /* Nil */0; } return x; } @@ -67,47 +67,47 @@ function take_queue(q) { } function pp_enqueue(state, token) { - state[13] += token[3]; - return add_queue(token, state[27]); + state[12] += token[2]; + return add_queue(token, state[26]); } function pp_clear_queue(state) { + state[11] = 1; state[12] = 1; - state[13] = 1; - var q = state[27]; + var q = state[26]; + q[0] = /* Nil */0; q[1] = /* Nil */0; - q[2] = /* Nil */0; return /* () */0; } var pp_infinity = 1000000010; function pp_output_string(state, s) { - return Caml_curry.app3(state[17], s, 0, s.length); + return Caml_curry.app3(state[16], s, 0, s.length); } function break_new_line(state, offset, width) { - Caml_curry.app1(state[19], /* () */0); - state[11] = /* true */1; - var indent = state[6] - width + offset; - var real_indent = Pervasives.min(state[8], indent); - state[10] = real_indent; - state[9] = state[6] - state[10]; - return Caml_curry.app1(state[20], state[10]); + Caml_curry.app1(state[18], /* () */0); + state[10] = /* true */1; + var indent = state[5] - width + offset; + var real_indent = Pervasives.min(state[7], indent); + state[9] = real_indent; + state[8] = state[5] - state[9]; + return Caml_curry.app1(state[19], state[9]); } function break_same_line(state, width) { - state[9] -= width; - return Caml_curry.app1(state[20], width); + state[8] -= width; + return Caml_curry.app1(state[19], width); } function pp_force_break_line(state) { - var match = state[2]; + var match = state[1]; if (match) { - var match$1 = match[1]; - var width = match$1[2]; - var bl_ty = match$1[1]; - if (width > state[9] && bl_ty !== 0 && bl_ty < 5) { + var match$1 = match[0]; + var width = match$1[1]; + var bl_ty = match$1[0]; + if (width > state[8] && bl_ty !== 0 && bl_ty < 5) { return break_new_line(state, 0, width); } else { @@ -115,7 +115,7 @@ function pp_force_break_line(state) { } } else { - return Caml_curry.app1(state[19], /* () */0); + return Caml_curry.app1(state[18], /* () */0); } } @@ -123,36 +123,33 @@ function format_pp_token(state, size, param) { if (typeof param === "number") { switch (param) { case 0 : - var match = state[3]; + var match = state[2]; if (match) { - var tabs = match[1][1]; + var tabs = match[0][0]; var add_tab = function (n, ls) { if (ls) { - var x = ls[1]; - if (Caml_primitive.caml_lessthan(n, x)) { - return [ - /* :: */0, + var x = ls[0]; + if (Caml_obj.caml_lessthan(n, x)) { + return /* :: */[ n, ls ]; } else { - return [ - /* :: */0, + return /* :: */[ x, - add_tab(n, ls[2]) + add_tab(n, ls[1]) ]; } } else { - return [ - /* :: */0, + return /* :: */[ n, /* [] */0 ]; } }; - tabs[1] = add_tab(state[6] - state[9], tabs[1]); + tabs[0] = add_tab(state[5] - state[8], tabs[0]); return /* () */0; } else { @@ -160,49 +157,49 @@ function format_pp_token(state, size, param) { } break; case 1 : - var match$1 = state[2]; + var match$1 = state[1]; if (match$1) { - state[2] = match$1[2]; + state[1] = match$1[1]; return /* () */0; } else { return /* () */0; } case 2 : - var match$2 = state[3]; + var match$2 = state[2]; if (match$2) { - state[3] = match$2[2]; + state[2] = match$2[1]; return /* () */0; } else { return /* () */0; } case 3 : - var match$3 = state[2]; + var match$3 = state[1]; if (match$3) { - return break_new_line(state, 0, match$3[1][2]); + return break_new_line(state, 0, match$3[0][1]); } else { - return Caml_curry.app1(state[19], /* () */0); + return Caml_curry.app1(state[18], /* () */0); } case 4 : - if (state[10] !== state[6] - state[9]) { + if (state[9] !== state[5] - state[8]) { var state$1 = state; - var match$4 = take_queue(state$1[27]); - var size$1 = match$4[1]; - state$1[12] -= match$4[3]; - state$1[9] += size$1; + var match$4 = take_queue(state$1[26]); + var size$1 = match$4[0]; + state$1[11] -= match$4[2]; + state$1[8] += size$1; return /* () */0; } else { return 0; } case 5 : - var match$5 = state[5]; + var match$5 = state[4]; if (match$5) { - var marker = Caml_curry.app1(state[24], match$5[1]); + var marker = Caml_curry.app1(state[23], match$5[0]); pp_output_string(state, marker); - state[5] = match$5[2]; + state[4] = match$5[1]; return /* () */0; } else { @@ -213,32 +210,32 @@ function format_pp_token(state, size, param) { } } else { - switch (param[0]) { + switch (param.tag | 0) { case 0 : - state[9] -= size; - pp_output_string(state, param[1]); - state[11] = /* false */0; + state[8] -= size; + pp_output_string(state, param[0]); + state[10] = /* false */0; return /* () */0; case 1 : - var off = param[2]; - var n = param[1]; - var match$6 = state[2]; + var off = param[1]; + var n = param[0]; + var match$6 = state[1]; if (match$6) { - var match$7 = match$6[1]; - var width = match$7[2]; - switch (match$7[1]) { + var match$7 = match$6[0]; + var width = match$7[1]; + switch (match$7[0]) { case 1 : case 2 : return break_new_line(state, off, width); case 3 : - if (size > state[9]) { + if (size > state[8]) { return break_new_line(state, off, width); } else { return break_same_line(state, n); } case 4 : - if (state[11] || !(size > state[9] || state[10] > state[6] - width + off)) { + if (state[10] || !(size > state[8] || state[9] > state[5] - width + off)) { return break_same_line(state, n); } else { @@ -255,20 +252,20 @@ function format_pp_token(state, size, param) { } break; case 2 : - var insertion_point = state[6] - state[9]; - var match$8 = state[3]; + var insertion_point = state[5] - state[8]; + var match$8 = state[2]; if (match$8) { - var tabs$1 = match$8[1][1]; + var tabs$1 = match$8[0][0]; var find = function (n, _param) { while(true) { var param = _param; if (param) { - var x = param[1]; - if (Caml_primitive.caml_greaterequal(x, n)) { + var x = param[0]; + if (Caml_obj.caml_greaterequal(x, n)) { return x; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -278,15 +275,15 @@ function format_pp_token(state, size, param) { } }; }; - var match$9 = tabs$1[1]; + var match$9 = tabs$1[0]; var tab; if (match$9) { try { - tab = find(insertion_point, tabs$1[1]); + tab = find(insertion_point, tabs$1[0]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - tab = match$9[1]; + tab = match$9[0]; } else { throw exn; @@ -298,10 +295,10 @@ function format_pp_token(state, size, param) { } var offset = tab - insertion_point; if (offset >= 0) { - return break_same_line(state, offset + param[1]); + return break_same_line(state, offset + param[0]); } else { - return break_new_line(state, tab + param[2], state[6]); + return break_new_line(state, tab + param[1], state[5]); } } else { @@ -309,40 +306,38 @@ function format_pp_token(state, size, param) { } break; case 3 : - var ty = param[2]; - var insertion_point$1 = state[6] - state[9]; - if (insertion_point$1 > state[8]) { + var ty = param[1]; + var insertion_point$1 = state[5] - state[8]; + if (insertion_point$1 > state[7]) { pp_force_break_line(state); } - var offset$1 = state[9] - param[1]; + var offset$1 = state[8] - param[0]; var bl_type = ty !== 1 ? ( - size > state[9] ? ty : /* Pp_fits */5 + size > state[8] ? ty : /* Pp_fits */5 ) : /* Pp_vbox */1; - state[2] = [ - /* :: */0, - [ - /* Format_elem */0, - bl_type, - offset$1 - ], - state[2] + state[1] = /* :: */[ + /* Format_elem */{ + 0: bl_type, + 1: offset$1, + length: 2, + tag: 0 + }, + state[1] ]; return /* () */0; case 4 : - state[3] = [ - /* :: */0, - param[1], - state[3] + state[2] = /* :: */[ + param[0], + state[2] ]; return /* () */0; case 5 : - var tag_name = param[1]; - var marker$1 = Caml_curry.app1(state[23], tag_name); + var tag_name = param[0]; + var marker$1 = Caml_curry.app1(state[22], tag_name); pp_output_string(state, marker$1); - state[5] = [ - /* :: */0, + state[4] = /* :: */[ tag_name, - state[5] + state[4] ]; return /* () */0; @@ -354,15 +349,15 @@ function advance_left(state) { try { var state$1 = state; while(true) { - var match = peek_queue(state$1[27]); - var size = match[1]; - if (size < 0 && state$1[13] - state$1[12] < state$1[9]) { + var match = peek_queue(state$1[26]); + var size = match[0]; + if (size < 0 && state$1[12] - state$1[11] < state$1[8]) { return 0; } else { - take_queue(state$1[27]); - format_pp_token(state$1, size < 0 ? pp_infinity : size, match[2]); - state$1[12] = match[3] + state$1[12]; + take_queue(state$1[26]); + format_pp_token(state$1, size < 0 ? pp_infinity : size, match[1]); + state$1[11] = match[2] + state$1[11]; continue ; } @@ -384,58 +379,58 @@ function enqueue_advance(state, tok) { } function enqueue_string_as(state, size, s) { - return enqueue_advance(state, [ - /* record */0, + return enqueue_advance(state, /* record */[ size, - [ - /* Pp_text */0, - s - ], + /* Pp_text */{ + 0: s, + length: 1, + tag: 0 + }, size ]); } -var q_elem = [ - /* record */0, +var q_elem = /* record */[ -1, - [ - /* Pp_text */0, - "" - ], + /* Pp_text */{ + 0: "", + length: 1, + tag: 0 + }, 0 ]; -var scan_stack_bottom_001 = [ - /* Scan_elem */0, - -1, - q_elem -]; +var scan_stack_bottom_000 = /* Scan_elem */{ + 0: -1, + 1: q_elem, + length: 2, + tag: 0 +}; -var scan_stack_bottom = [ - /* :: */0, - scan_stack_bottom_001, +var scan_stack_bottom = /* :: */[ + scan_stack_bottom_000, /* [] */0 ]; function set_size(state, ty) { - var match = state[1]; + var match = state[0]; if (match) { - var match$1 = match[1]; - var queue_elem = match$1[2]; - var size = queue_elem[1]; - var t = match[2]; - if (match$1[1] < state[12]) { - state[1] = scan_stack_bottom; + var match$1 = match[0]; + var queue_elem = match$1[1]; + var size = queue_elem[0]; + var t = match[1]; + if (match$1[0] < state[11]) { + state[0] = scan_stack_bottom; return /* () */0; } else { var exit = 0; - var $js = queue_elem[2]; + var $js = queue_elem[1]; if (typeof $js === "number") { return /* () */0; } else { - switch ($js[0]) { + switch ($js.tag | 0) { case 1 : case 2 : exit = 1; @@ -445,8 +440,8 @@ function set_size(state, ty) { return 0; } else { - queue_elem[1] = state[13] + size; - state[1] = t; + queue_elem[0] = state[12] + size; + state[0] = t; return /* () */0; } default: @@ -455,8 +450,8 @@ function set_size(state, ty) { } if (exit === 1) { if (ty) { - queue_elem[1] = state[13] + size; - state[1] = t; + queue_elem[0] = state[12] + size; + state[0] = t; return /* () */0; } else { @@ -476,36 +471,36 @@ function scan_push(state, b, tok) { if (b) { set_size(state, /* true */1); } - state[1] = [ - /* :: */0, - [ - /* Scan_elem */0, - state[13], - tok - ], - state[1] + state[0] = /* :: */[ + /* Scan_elem */{ + 0: state[12], + 1: tok, + length: 2, + tag: 0 + }, + state[0] ]; return /* () */0; } function pp_open_box_gen(state, indent, br_ty) { - ++ state[14]; - if (state[14] < state[15]) { - var elem = [ - /* record */0, - -state[13], - [ - /* Pp_begin */3, - indent, - br_ty - ], + ++ state[13]; + if (state[13] < state[14]) { + var elem = /* record */[ + -state[12], + /* Pp_begin */{ + 0: indent, + 1: br_ty, + length: 2, + tag: 3 + }, 0 ]; return scan_push(state, /* false */0, elem); } - else if (state[14] === state[15]) { + else if (state[13] === state[14]) { var state$1 = state; - var s = state[16]; + var s = state[15]; var len = s.length; return enqueue_string_as(state$1, len, s); } @@ -515,10 +510,9 @@ function pp_open_box_gen(state, indent, br_ty) { } function pp_close_box(state, _) { - if (state[14] > 1) { - if (state[14] < state[15]) { - pp_enqueue(state, [ - /* record */0, + if (state[13] > 1) { + if (state[13] < state[14]) { + pp_enqueue(state, /* record */[ 0, /* Pp_end */1, 0 @@ -526,7 +520,7 @@ function pp_close_box(state, _) { set_size(state, /* true */1); set_size(state, /* false */0); } - -- state[14]; + -- state[13]; return /* () */0; } else { @@ -535,22 +529,21 @@ function pp_close_box(state, _) { } function pp_open_tag(state, tag_name) { - if (state[21]) { - state[4] = [ - /* :: */0, + if (state[20]) { + state[3] = /* :: */[ tag_name, - state[4] + state[3] ]; - Caml_curry.app1(state[25], tag_name); + Caml_curry.app1(state[24], tag_name); } - if (state[22]) { - return pp_enqueue(state, [ - /* record */0, + if (state[21]) { + return pp_enqueue(state, /* record */[ 0, - [ - /* Pp_open_tag */5, - tag_name - ], + /* Pp_open_tag */{ + 0: tag_name, + length: 1, + tag: 5 + }, 0 ]); } @@ -560,19 +553,18 @@ function pp_open_tag(state, tag_name) { } function pp_close_tag(state, _) { - if (state[22]) { - pp_enqueue(state, [ - /* record */0, + if (state[21]) { + pp_enqueue(state, /* record */[ 0, /* Pp_close_tag */5, 0 ]); } - if (state[21]) { - var match = state[4]; + if (state[20]) { + var match = state[3]; if (match) { - Caml_curry.app1(state[26], match[1]); - state[4] = match[2]; + Caml_curry.app1(state[25], match[0]); + state[3] = match[1]; return /* () */0; } else { @@ -585,74 +577,73 @@ function pp_close_tag(state, _) { } function pp_set_print_tags(state, b) { - state[21] = b; + state[20] = b; return /* () */0; } function pp_set_mark_tags(state, b) { - state[22] = b; + state[21] = b; return /* () */0; } function pp_get_print_tags(state, _) { - return state[21]; + return state[20]; } function pp_get_mark_tags(state, _) { - return state[22]; + return state[21]; } function pp_set_tags(state, b) { + state[20] = b; state[21] = b; - state[22] = b; return /* () */0; } function pp_get_formatter_tag_functions(state, _) { - return [ - /* record */0, + return /* record */[ + state[22], state[23], state[24], - state[25], - state[26] + state[25] ]; } function pp_set_formatter_tag_functions(state, param) { + state[22] = param[0]; state[23] = param[1]; state[24] = param[2]; state[25] = param[3]; - state[26] = param[4]; return /* () */0; } function pp_rinit(state) { pp_clear_queue(state); - state[1] = scan_stack_bottom; + state[0] = scan_stack_bottom; + state[1] = /* [] */0; state[2] = /* [] */0; state[3] = /* [] */0; state[4] = /* [] */0; - state[5] = /* [] */0; - state[10] = 0; - state[14] = 0; - state[9] = state[6]; + state[9] = 0; + state[13] = 0; + state[8] = state[5]; return pp_open_box_gen(state, 0, /* Pp_hovbox */3); } function pp_flush_queue(state, b) { - while(state[14] > 1) { + while(state[13] > 1) { pp_close_box(state, /* () */0); }; - state[13] = pp_infinity; + state[12] = pp_infinity; advance_left(state); if (b) { - Caml_curry.app1(state[19], /* () */0); + Caml_curry.app1(state[18], /* () */0); } return pp_rinit(state); } function pp_print_as_size(state, size, s) { - if (state[14] < state[15]) { + if (state[13] < state[14]) { return enqueue_string_as(state, size, s); } else { @@ -706,18 +697,17 @@ function pp_open_box(state, indent) { function pp_print_newline(state, _) { pp_flush_queue(state, /* true */1); - return Caml_curry.app1(state[18], /* () */0); + return Caml_curry.app1(state[17], /* () */0); } function pp_print_flush(state, _) { pp_flush_queue(state, /* false */0); - return Caml_curry.app1(state[18], /* () */0); + return Caml_curry.app1(state[17], /* () */0); } function pp_force_newline(state, _) { - if (state[14] < state[15]) { - return enqueue_advance(state, [ - /* record */0, + if (state[13] < state[14]) { + return enqueue_advance(state, /* record */[ 0, /* Pp_newline */3, 0 @@ -729,9 +719,8 @@ function pp_force_newline(state, _) { } function pp_print_if_newline(state, _) { - if (state[14] < state[15]) { - return enqueue_advance(state, [ - /* record */0, + if (state[13] < state[14]) { + return enqueue_advance(state, /* record */[ 0, /* Pp_if_newline */4, 0 @@ -743,15 +732,15 @@ function pp_print_if_newline(state, _) { } function pp_print_break(state, width, offset) { - if (state[14] < state[15]) { - var elem = [ - /* record */0, - -state[13], - [ - /* Pp_break */1, - width, - offset - ], + if (state[13] < state[14]) { + var elem = /* record */[ + -state[12], + /* Pp_break */{ + 0: width, + 1: offset, + length: 2, + tag: 1 + }, width ]; return scan_push(state, /* true */1, elem); @@ -770,21 +759,19 @@ function pp_print_cut(state, _) { } function pp_open_tbox(state, _) { - ++ state[14]; - if (state[14] < state[15]) { - var elem = [ - /* record */0, + ++ state[13]; + if (state[13] < state[14]) { + var elem = /* record */[ 0, - [ - /* Pp_tbegin */4, - [ - /* Pp_tbox */0, - [ - 0, - /* [] */0 - ] - ] - ], + /* Pp_tbegin */{ + 0: /* Pp_tbox */{ + 0: [/* [] */0], + length: 1, + tag: 0 + }, + length: 1, + tag: 4 + }, 0 ]; return enqueue_advance(state, elem); @@ -795,16 +782,15 @@ function pp_open_tbox(state, _) { } function pp_close_tbox(state, _) { - if (state[14] > 1) { - if (state[14] < state[15]) { - var elem = [ - /* record */0, + if (state[13] > 1) { + if (state[13] < state[14]) { + var elem = /* record */[ 0, /* Pp_tend */2, 0 ]; enqueue_advance(state, elem); - -- state[14]; + -- state[13]; return /* () */0; } else { @@ -817,15 +803,15 @@ function pp_close_tbox(state, _) { } function pp_print_tbreak(state, width, offset) { - if (state[14] < state[15]) { - var elem = [ - /* record */0, - -state[13], - [ - /* Pp_tbreak */2, - width, - offset - ], + if (state[13] < state[14]) { + var elem = /* record */[ + -state[12], + /* Pp_tbreak */{ + 0: width, + 1: offset, + length: 2, + tag: 2 + }, width ]; return scan_push(state, /* true */1, elem); @@ -840,9 +826,8 @@ function pp_print_tab(state, _) { } function pp_set_tab(state, _) { - if (state[14] < state[15]) { - var elem = [ - /* record */0, + if (state[13] < state[14]) { + var elem = /* record */[ 0, /* Pp_stab */0, 0 @@ -858,18 +843,15 @@ function pp_print_list(_$staropt$star, pp_v, ppf, _param) { while(true) { var param = _param; var $staropt$star = _$staropt$star; - var pp_sep = $staropt$star ? $staropt$star[1] : pp_print_cut; + var pp_sep = $staropt$star ? $staropt$star[0] : pp_print_cut; if (param) { - var vs = param[2]; - var v = param[1]; + var vs = param[1]; + var v = param[0]; if (vs) { Caml_curry.app2(pp_v, ppf, v); Caml_curry.app2(pp_sep, ppf, /* () */0); _param = vs; - _$staropt$star = [ - /* Some */0, - pp_sep - ]; + _$staropt$star = /* Some */[pp_sep]; continue ; } @@ -885,25 +867,19 @@ function pp_print_list(_$staropt$star, pp_v, ppf, _param) { function pp_print_text(ppf, s) { var len = s.length; - var left = [ - 0, - 0 - ]; - var right = [ - 0, - 0 - ]; + var left = [0]; + var right = [0]; var flush = function () { - pp_print_string(ppf, $$String.sub(s, left[1], right[1] - left[1])); - ++ right[1]; - left[1] = right[1]; + pp_print_string(ppf, $$String.sub(s, left[0], right[0] - left[0])); + ++ right[0]; + left[0] = right[0]; return /* () */0; }; - while(right[1] !== len) { - var match = s.charCodeAt(right[1]); + while(right[0] !== len) { + var match = s.charCodeAt(right[0]); if (match !== 10) { if (match !== 32) { - ++ right[1]; + ++ right[0]; } else { flush(/* () */0); @@ -915,7 +891,7 @@ function pp_print_text(ppf, s) { pp_force_newline(ppf, /* () */0); } }; - if (left[1] !== len) { + if (left[0] !== len) { return flush(/* () */0); } else { @@ -925,7 +901,7 @@ function pp_print_text(ppf, s) { function pp_set_max_boxes(state, n) { if (n > 1) { - state[15] = n; + state[14] = n; return /* () */0; } else { @@ -934,20 +910,20 @@ function pp_set_max_boxes(state, n) { } function pp_get_max_boxes(state, _) { - return state[15]; + return state[14]; } function pp_over_max_boxes(state, _) { - return +(state[14] === state[15]); + return +(state[13] === state[14]); } function pp_set_ellipsis_text(state, s) { - state[16] = s; + state[15] = s; return /* () */0; } function pp_get_ellipsis_text(state, _) { - return state[16]; + return state[15]; } function pp_limit(n) { @@ -961,11 +937,11 @@ function pp_limit(n) { function pp_set_max_indent(state, n) { var state$1 = state; - var n$1 = state[6] - n; + var n$1 = state[5] - n; if (n$1 >= 1) { var n$2 = pp_limit(n$1); - state$1[7] = n$2; - state$1[8] = state$1[6] - state$1[7]; + state$1[6] = n$2; + state$1[7] = state$1[5] - state$1[6]; return pp_rinit(state$1); } else { @@ -974,14 +950,14 @@ function pp_set_max_indent(state, n) { } function pp_get_max_indent(state, _) { - return state[8]; + return state[7]; } function pp_set_margin(state, n) { if (n >= 1) { var n$1 = pp_limit(n); - state[6] = n$1; - var new_max_indent = state[8] <= state[6] ? state[8] : Pervasives.max(Pervasives.max(state[6] - state[7], state[6] / 2 | 0), 1); + state[5] = n$1; + var new_max_indent = state[7] <= state[5] ? state[7] : Pervasives.max(Pervasives.max(state[5] - state[6], state[5] / 2 | 0), 1); return pp_set_max_indent(state, new_max_indent); } else { @@ -990,60 +966,57 @@ function pp_set_margin(state, n) { } function pp_get_margin(state, _) { - return state[6]; + return state[5]; } function pp_set_formatter_out_functions(state, param) { + state[16] = param[0]; state[17] = param[1]; state[18] = param[2]; state[19] = param[3]; - state[20] = param[4]; return /* () */0; } function pp_get_formatter_out_functions(state, _) { - return [ - /* record */0, + return /* record */[ + state[16], state[17], state[18], - state[19], - state[20] + state[19] ]; } function pp_set_formatter_output_functions(state, f, g) { - state[17] = f; - state[18] = g; + state[16] = f; + state[17] = g; return /* () */0; } function pp_get_formatter_output_functions(state, _) { - return [ - /* tuple */0, - state[17], - state[18] + return /* tuple */[ + state[16], + state[17] ]; } function pp_set_all_formatter_output_functions(state, f, g, h, i) { pp_set_formatter_output_functions(state, f, g); - state[19] = h; - state[20] = i; + state[18] = h; + state[19] = i; return /* () */0; } function pp_get_all_formatter_output_functions(state, _) { - return [ - /* tuple */0, + return /* tuple */[ + state[16], state[17], state[18], - state[19], - state[20] + state[19] ]; } function display_newline(state, _) { - return Caml_curry.app3(state[17], "\n", 0, 1); + return Caml_curry.app3(state[16], "\n", 0, 1); } var blank_line = $$String.make(80, /* " " */32); @@ -1053,10 +1026,10 @@ function display_blanks(state, _n) { var n = _n; if (n > 0) { if (n <= 80) { - return Caml_curry.app3(state[17], blank_line, 0, n); + return Caml_curry.app3(state[16], blank_line, 0, n); } else { - Caml_curry.app3(state[17], blank_line, 0, 80); + Caml_curry.app3(state[16], blank_line, 0, 80); _n = n - 80; continue ; @@ -1069,16 +1042,16 @@ function display_blanks(state, _n) { } function pp_set_formatter_out_channel(state, os) { - state[17] = function (param, param$1, param$2) { + state[16] = function (param, param$1, param$2) { return Pervasives.output_substring(os, param, param$1, param$2); }; - state[18] = function () { + state[17] = function () { return Caml_io.caml_ml_flush(os); }; - state[19] = function (param) { + state[18] = function (param) { return display_newline(state, param); }; - state[20] = function (param) { + state[19] = function (param) { return display_blanks(state, param); }; return /* () */0; @@ -1101,34 +1074,32 @@ function default_pp_print_close_tag(prim) { } function pp_make_formatter(f, g, h, i) { - var pp_q = [ - /* record */0, + var pp_q = /* record */[ /* Nil */0, /* Nil */0 ]; - var sys_tok = [ - /* record */0, + var sys_tok = /* record */[ -1, - [ - /* Pp_begin */3, - 0, - /* Pp_hovbox */3 - ], + /* Pp_begin */{ + 0: 0, + 1: /* Pp_hovbox */3, + length: 2, + tag: 3 + }, 0 ]; add_queue(sys_tok, pp_q); - var sys_scan_stack_001 = [ - /* Scan_elem */0, - 1, - sys_tok - ]; - var sys_scan_stack = [ - /* :: */0, - sys_scan_stack_001, + var sys_scan_stack_000 = /* Scan_elem */{ + 0: 1, + 1: sys_tok, + length: 2, + tag: 0 + }; + var sys_scan_stack = /* :: */[ + sys_scan_stack_000, scan_stack_bottom ]; - return [ - /* record */0, + return /* record */[ sys_scan_stack, /* [] */0, /* [] */0, @@ -1165,10 +1136,10 @@ function make_formatter(output, flush) { }, function (prim) { return prim; }); - ppf[19] = function (param) { + ppf[18] = function (param) { return display_newline(ppf, param); }; - ppf[20] = function (param) { + ppf[19] = function (param) { return display_blanks(ppf, param); }; return ppf; @@ -1321,7 +1292,7 @@ function set_margin(param) { } function get_margin() { - return std_formatter[6]; + return std_formatter[5]; } function set_max_indent(param) { @@ -1329,7 +1300,7 @@ function set_max_indent(param) { } function get_max_indent() { - return std_formatter[8]; + return std_formatter[7]; } function set_max_boxes(param) { @@ -1337,7 +1308,7 @@ function set_max_boxes(param) { } function get_max_boxes() { - return std_formatter[15]; + return std_formatter[14]; } function over_max_boxes(param) { @@ -1345,12 +1316,12 @@ function over_max_boxes(param) { } function set_ellipsis_text(param) { - std_formatter[16] = param; + std_formatter[15] = param; return /* () */0; } function get_ellipsis_text() { - return std_formatter[16]; + return std_formatter[15]; } function set_formatter_out_channel(param) { @@ -1390,21 +1361,21 @@ function get_formatter_tag_functions(param) { } function set_print_tags(param) { - std_formatter[21] = param; + std_formatter[20] = param; return /* () */0; } function get_print_tags() { - return std_formatter[21]; + return std_formatter[20]; } function set_mark_tags(param) { - std_formatter[22] = param; + std_formatter[21] = param; return /* () */0; } function get_mark_tags() { - return std_formatter[22]; + return std_formatter[21]; } function set_tags(param) { @@ -1416,7 +1387,7 @@ function compute_tag(output, tag_acc) { var ppf = formatter_of_buffer(buf); Caml_curry.app2(output, ppf, tag_acc); pp_print_flush(ppf, /* () */0); - var len = buf[2]; + var len = buf[1]; if (len < 2) { return Buffer.contents(buf); } @@ -1446,14 +1417,14 @@ function output_formatting_lit(ppf, fmting_lit) { } } else { - switch (fmting_lit[0]) { + switch (fmting_lit.tag | 0) { case 0 : - return pp_print_break(ppf, fmting_lit[2], fmting_lit[3]); + return pp_print_break(ppf, fmting_lit[1], fmting_lit[2]); case 1 : return /* () */0; case 2 : pp_print_char(ppf, /* "@" */64); - return pp_print_char(ppf, fmting_lit[1]); + return pp_print_char(ppf, fmting_lit[0]); } } @@ -1471,40 +1442,40 @@ function output_acc(ppf, acc) { return /* () */0; } else { - switch (acc[0]) { + switch (acc.tag | 0) { case 0 : - output_acc(ppf, acc[1]); - return output_formatting_lit(ppf, acc[2]); + output_acc(ppf, acc[0]); + return output_formatting_lit(ppf, acc[1]); case 1 : - var match = acc[2]; - var p$2 = acc[1]; + var match = acc[1]; + var p$2 = acc[0]; output_acc(ppf, p$2); - if (match[0]) { - var match$1 = CamlinternalFormat.open_box_of_string(compute_tag(output_acc, match[1])); - return pp_open_box_gen(ppf, match$1[1], match$1[2]); + if (match.tag) { + var match$1 = CamlinternalFormat.open_box_of_string(compute_tag(output_acc, match[0])); + return pp_open_box_gen(ppf, match$1[0], match$1[1]); } else { - return pp_open_tag(ppf, compute_tag(output_acc, match[1])); + return pp_open_tag(ppf, compute_tag(output_acc, match[0])); } break; case 2 : - var p$3 = acc[1]; + var p$3 = acc[0]; var exit$1 = 0; if (typeof p$3 === "number") { exit$1 = 3; } - else if (p$3[0]) { + else if (p$3.tag) { exit$1 = 3; } else { - var match$2 = p$3[2]; + var match$2 = p$3[1]; if (typeof match$2 === "number") { exit$1 = 3; } - else if (match$2[0] === 1) { - p = p$3[1]; - size = match$2[2]; - s = acc[2]; + else if (match$2.tag === 1) { + p = p$3[0]; + size = match$2[1]; + s = acc[1]; exit = 1; } else { @@ -1513,27 +1484,27 @@ function output_acc(ppf, acc) { } if (exit$1 === 3) { output_acc(ppf, p$3); - return pp_print_string(ppf, acc[2]); + return pp_print_string(ppf, acc[1]); } break; case 3 : - var p$4 = acc[1]; + var p$4 = acc[0]; var exit$2 = 0; if (typeof p$4 === "number") { exit$2 = 3; } - else if (p$4[0]) { + else if (p$4.tag) { exit$2 = 3; } else { - var match$3 = p$4[2]; + var match$3 = p$4[1]; if (typeof match$3 === "number") { exit$2 = 3; } - else if (match$3[0] === 1) { - p$1 = p$4[1]; - size$1 = match$3[2]; - c = acc[2]; + else if (match$3.tag === 1) { + p$1 = p$4[0]; + size$1 = match$3[1]; + c = acc[1]; exit = 2; } else { @@ -1542,27 +1513,27 @@ function output_acc(ppf, acc) { } if (exit$2 === 3) { output_acc(ppf, p$4); - return pp_print_char(ppf, acc[2]); + return pp_print_char(ppf, acc[1]); } break; case 4 : - var p$5 = acc[1]; + var p$5 = acc[0]; var exit$3 = 0; if (typeof p$5 === "number") { exit$3 = 3; } - else if (p$5[0]) { + else if (p$5.tag) { exit$3 = 3; } else { - var match$4 = p$5[2]; + var match$4 = p$5[1]; if (typeof match$4 === "number") { exit$3 = 3; } - else if (match$4[0] === 1) { - p = p$5[1]; - size = match$4[2]; - s = acc[2]; + else if (match$4.tag === 1) { + p = p$5[0]; + size = match$4[1]; + s = acc[1]; exit = 1; } else { @@ -1571,27 +1542,27 @@ function output_acc(ppf, acc) { } if (exit$3 === 3) { output_acc(ppf, p$5); - return pp_print_string(ppf, acc[2]); + return pp_print_string(ppf, acc[1]); } break; case 5 : - var p$6 = acc[1]; + var p$6 = acc[0]; var exit$4 = 0; if (typeof p$6 === "number") { exit$4 = 3; } - else if (p$6[0]) { + else if (p$6.tag) { exit$4 = 3; } else { - var match$5 = p$6[2]; + var match$5 = p$6[1]; if (typeof match$5 === "number") { exit$4 = 3; } - else if (match$5[0] === 1) { - p$1 = p$6[1]; - size$1 = match$5[2]; - c = acc[2]; + else if (match$5.tag === 1) { + p$1 = p$6[0]; + size$1 = match$5[1]; + c = acc[1]; exit = 2; } else { @@ -1600,21 +1571,20 @@ function output_acc(ppf, acc) { } if (exit$4 === 3) { output_acc(ppf, p$6); - return pp_print_char(ppf, acc[2]); + return pp_print_char(ppf, acc[1]); } break; case 6 : - output_acc(ppf, acc[1]); - return Caml_curry.app1(acc[2], ppf); + output_acc(ppf, acc[0]); + return Caml_curry.app1(acc[1], ppf); case 7 : - output_acc(ppf, acc[1]); + output_acc(ppf, acc[0]); return pp_print_flush(ppf, /* () */0); case 8 : - output_acc(ppf, acc[1]); + output_acc(ppf, acc[0]); throw [ - 0, Caml_builtin_exceptions.Invalid_argument, - acc[2] + acc[1] ]; } @@ -1642,40 +1612,40 @@ function strput_acc(ppf, acc) { return /* () */0; } else { - switch (acc[0]) { + switch (acc.tag | 0) { case 0 : - strput_acc(ppf, acc[1]); - return output_formatting_lit(ppf, acc[2]); + strput_acc(ppf, acc[0]); + return output_formatting_lit(ppf, acc[1]); case 1 : - var match = acc[2]; - var p$2 = acc[1]; + var match = acc[1]; + var p$2 = acc[0]; strput_acc(ppf, p$2); - if (match[0]) { - var match$1 = CamlinternalFormat.open_box_of_string(compute_tag(strput_acc, match[1])); - return pp_open_box_gen(ppf, match$1[1], match$1[2]); + if (match.tag) { + var match$1 = CamlinternalFormat.open_box_of_string(compute_tag(strput_acc, match[0])); + return pp_open_box_gen(ppf, match$1[0], match$1[1]); } else { - return pp_open_tag(ppf, compute_tag(strput_acc, match[1])); + return pp_open_tag(ppf, compute_tag(strput_acc, match[0])); } break; case 2 : - var p$3 = acc[1]; + var p$3 = acc[0]; var exit$1 = 0; if (typeof p$3 === "number") { exit$1 = 3; } - else if (p$3[0]) { + else if (p$3.tag) { exit$1 = 3; } else { - var match$2 = p$3[2]; + var match$2 = p$3[1]; if (typeof match$2 === "number") { exit$1 = 3; } - else if (match$2[0] === 1) { - p = p$3[1]; - size = match$2[2]; - s = acc[2]; + else if (match$2.tag === 1) { + p = p$3[0]; + size = match$2[1]; + s = acc[1]; exit = 1; } else { @@ -1684,27 +1654,27 @@ function strput_acc(ppf, acc) { } if (exit$1 === 3) { strput_acc(ppf, p$3); - return pp_print_string(ppf, acc[2]); + return pp_print_string(ppf, acc[1]); } break; case 3 : - var p$4 = acc[1]; + var p$4 = acc[0]; var exit$2 = 0; if (typeof p$4 === "number") { exit$2 = 3; } - else if (p$4[0]) { + else if (p$4.tag) { exit$2 = 3; } else { - var match$3 = p$4[2]; + var match$3 = p$4[1]; if (typeof match$3 === "number") { exit$2 = 3; } - else if (match$3[0] === 1) { - p$1 = p$4[1]; - size$1 = match$3[2]; - c = acc[2]; + else if (match$3.tag === 1) { + p$1 = p$4[0]; + size$1 = match$3[1]; + c = acc[1]; exit = 2; } else { @@ -1713,27 +1683,27 @@ function strput_acc(ppf, acc) { } if (exit$2 === 3) { strput_acc(ppf, p$4); - return pp_print_char(ppf, acc[2]); + return pp_print_char(ppf, acc[1]); } break; case 4 : - var p$5 = acc[1]; + var p$5 = acc[0]; var exit$3 = 0; if (typeof p$5 === "number") { exit$3 = 3; } - else if (p$5[0]) { + else if (p$5.tag) { exit$3 = 3; } else { - var match$4 = p$5[2]; + var match$4 = p$5[1]; if (typeof match$4 === "number") { exit$3 = 3; } - else if (match$4[0] === 1) { - p = p$5[1]; - size = match$4[2]; - s = acc[2]; + else if (match$4.tag === 1) { + p = p$5[0]; + size = match$4[1]; + s = acc[1]; exit = 1; } else { @@ -1742,27 +1712,27 @@ function strput_acc(ppf, acc) { } if (exit$3 === 3) { strput_acc(ppf, p$5); - return pp_print_string(ppf, acc[2]); + return pp_print_string(ppf, acc[1]); } break; case 5 : - var p$6 = acc[1]; + var p$6 = acc[0]; var exit$4 = 0; if (typeof p$6 === "number") { exit$4 = 3; } - else if (p$6[0]) { + else if (p$6.tag) { exit$4 = 3; } else { - var match$5 = p$6[2]; + var match$5 = p$6[1]; if (typeof match$5 === "number") { exit$4 = 3; } - else if (match$5[0] === 1) { - p$1 = p$6[1]; - size$1 = match$5[2]; - c = acc[2]; + else if (match$5.tag === 1) { + p$1 = p$6[0]; + size$1 = match$5[1]; + c = acc[1]; exit = 2; } else { @@ -1771,26 +1741,26 @@ function strput_acc(ppf, acc) { } if (exit$4 === 3) { strput_acc(ppf, p$6); - return pp_print_char(ppf, acc[2]); + return pp_print_char(ppf, acc[1]); } break; case 6 : - var p$7 = acc[1]; + var p$7 = acc[0]; var exit$5 = 0; if (typeof p$7 === "number") { exit$5 = 3; } - else if (p$7[0]) { + else if (p$7.tag) { exit$5 = 3; } else { - var match$6 = p$7[2]; + var match$6 = p$7[1]; if (typeof match$6 === "number") { exit$5 = 3; } - else if (match$6[0] === 1) { - strput_acc(ppf, p$7[1]); - return pp_print_as_size(ppf, match$6[2], Caml_curry.app1(acc[2], /* () */0)); + else if (match$6.tag === 1) { + strput_acc(ppf, p$7[0]); + return pp_print_as_size(ppf, match$6[1], Caml_curry.app1(acc[1], /* () */0)); } else { exit$5 = 3; @@ -1798,18 +1768,17 @@ function strput_acc(ppf, acc) { } if (exit$5 === 3) { strput_acc(ppf, p$7); - return pp_print_string(ppf, Caml_curry.app1(acc[2], /* () */0)); + return pp_print_string(ppf, Caml_curry.app1(acc[1], /* () */0)); } break; case 7 : - strput_acc(ppf, acc[1]); + strput_acc(ppf, acc[0]); return pp_print_flush(ppf, /* () */0); case 8 : - strput_acc(ppf, acc[1]); + strput_acc(ppf, acc[0]); throw [ - 0, Caml_builtin_exceptions.Invalid_argument, - acc[2] + acc[1] ]; } @@ -1829,13 +1798,13 @@ function kfprintf(k, o, param) { return CamlinternalFormat.make_printf(function (o, acc) { output_acc(o, acc); return Caml_curry.app1(k, o); - }, o, /* End_of_acc */0, param[1]); + }, o, /* End_of_acc */0, param[0]); } function ikfprintf(k, x, param) { return CamlinternalFormat.make_printf(function (_, _$1) { return Caml_curry.app1(k, x); - }, x, /* End_of_acc */0, param[1]); + }, x, /* End_of_acc */0, param[0]); } function fprintf(ppf, fmt) { @@ -1865,7 +1834,7 @@ function ksprintf(k, param) { strput_acc(ppf, acc); return Caml_curry.app1(k, flush_buf_formatter(b, ppf)); }; - return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[1]); + return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[0]); } function sprintf(fmt) { @@ -1882,7 +1851,7 @@ function asprintf(param) { pp_flush_queue(ppf, /* false */0); return flush_buf_formatter(b, ppf); }; - return CamlinternalFormat.make_printf(k$prime, ppf, /* End_of_acc */0, param[1]); + return CamlinternalFormat.make_printf(k$prime, ppf, /* End_of_acc */0, param[0]); } function bprintf(b, param) { @@ -1890,7 +1859,7 @@ function bprintf(b, param) { output_acc(ppf, acc); return pp_flush_queue(ppf, /* false */0); }; - return CamlinternalFormat.make_printf(k, formatter_of_buffer(b), /* End_of_acc */0, param[1]); + return CamlinternalFormat.make_printf(k, formatter_of_buffer(b), /* End_of_acc */0, param[0]); } Pervasives.at_exit(print_flush); diff --git a/jscomp/stdlib/gc.js b/jscomp/stdlib/gc.js index 4cac67a231..46aa253c50 100644 --- a/jscomp/stdlib/gc.js +++ b/jscomp/stdlib/gc.js @@ -6,300 +6,363 @@ var Printf = require("./printf"); var Caml_curry = require("../runtime/caml_curry"); function print_stat(c) { - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "minor_words: ", - [ - /* Float */8, - /* Float_f */0, - /* No_padding */0, - [ - /* Lit_precision */0, - 0 - ], - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "minor_words: %.0f\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "promoted_words: ", - [ - /* Float */8, - /* Float_f */0, - /* No_padding */0, - [ - /* Lit_precision */0, - 0 - ], - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "promoted_words: %.0f\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "major_words: ", - [ - /* Float */8, - /* Float_f */0, - /* No_padding */0, - [ - /* Lit_precision */0, - 0 - ], - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "major_words: %.0f\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "minor_collections: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "minor_collections: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "major_collections: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "major_collections: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "heap_words: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "heap_words: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "heap_chunks: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "heap_chunks: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "top_heap_words: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "top_heap_words: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "live_words: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "live_words: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "live_blocks: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "live_blocks: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "free_words: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "free_words: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "free_blocks: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "free_blocks: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "largest_free: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "largest_free: %d\n" - ]), 0); - Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "fragments: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "fragments: %d\n" - ]), 0); - return Caml_curry.app1(Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "compactions: ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "compactions: %d\n" - ]), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "minor_words: ", + 1: /* Float */{ + 0: /* Float_f */0, + 1: /* No_padding */0, + 2: /* Lit_precision */{ + 0: 0, + length: 1, + tag: 0 + }, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 8 + }, + length: 2, + tag: 11 + }, + 1: "minor_words: %.0f\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "promoted_words: ", + 1: /* Float */{ + 0: /* Float_f */0, + 1: /* No_padding */0, + 2: /* Lit_precision */{ + 0: 0, + length: 1, + tag: 0 + }, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 8 + }, + length: 2, + tag: 11 + }, + 1: "promoted_words: %.0f\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "major_words: ", + 1: /* Float */{ + 0: /* Float_f */0, + 1: /* No_padding */0, + 2: /* Lit_precision */{ + 0: 0, + length: 1, + tag: 0 + }, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 8 + }, + length: 2, + tag: 11 + }, + 1: "major_words: %.0f\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "minor_collections: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "minor_collections: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "major_collections: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "major_collections: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "heap_words: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "heap_words: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "heap_chunks: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "heap_chunks: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "top_heap_words: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "top_heap_words: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "live_words: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "live_words: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "live_blocks: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "live_blocks: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "free_words: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "free_words: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "free_blocks: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "free_blocks: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "largest_free: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "largest_free: %d\n", + length: 2, + tag: 0 + }), 0); + Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "fragments: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "fragments: %d\n", + length: 2, + tag: 0 + }), 0); + return Caml_curry.app1(Printf.fprintf(c, /* Format */{ + 0: /* String_literal */{ + 0: "compactions: ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "compactions: %d\n", + length: 2, + tag: 0 + }), 0); } function allocated_bytes() { @@ -307,15 +370,12 @@ function allocated_bytes() { } function create_alarm(f) { - var arec_001 = [ - 0, - /* true */1 - ]; - return arec_001; + var arec_000 = [/* true */1]; + return arec_000; } function delete_alarm(a) { - a[1] = /* false */0; + a[0] = /* false */0; return /* () */0; } diff --git a/jscomp/stdlib/genlex.js b/jscomp/stdlib/genlex.js index 88e2582184..a4f0463754 100644 --- a/jscomp/stdlib/genlex.js +++ b/jscomp/stdlib/genlex.js @@ -13,45 +13,40 @@ var List = require("./list"); var initial_buffer = new Array(32); -var buffer = [ - 0, - initial_buffer -]; +var buffer = [initial_buffer]; -var bufpos = [ - 0, - 0 -]; +var bufpos = [0]; function reset_buffer() { - buffer[1] = initial_buffer; - bufpos[1] = 0; + buffer[0] = initial_buffer; + bufpos[0] = 0; return /* () */0; } function store(c) { - if (bufpos[1] >= buffer[1].length) { - var newbuffer = Caml_string.caml_create_string(2 * bufpos[1]); - Bytes.blit(buffer[1], 0, newbuffer, 0, bufpos[1]); - buffer[1] = newbuffer; + if (bufpos[0] >= buffer[0].length) { + var newbuffer = Caml_string.caml_create_string(2 * bufpos[0]); + Bytes.blit(buffer[0], 0, newbuffer, 0, bufpos[0]); + buffer[0] = newbuffer; } - buffer[1][bufpos[1]] = c; - return ++ bufpos[1]; + buffer[0][bufpos[0]] = c; + return ++ bufpos[0]; } function get_string() { - var s = Bytes.sub_string(buffer[1], 0, bufpos[1]); - buffer[1] = initial_buffer; + var s = Bytes.sub_string(buffer[0], 0, bufpos[0]); + buffer[0] = initial_buffer; return s; } function make_lexer(keywords) { var kwd_table = Hashtbl.create(/* None */0, 17); List.iter(function (s) { - return Hashtbl.add(kwd_table, s, [ - /* Kwd */0, - s - ]); + return Hashtbl.add(kwd_table, s, /* Kwd */{ + 0: s, + length: 1, + tag: 0 + }); }, keywords); var ident_or_keyword = function (id) { try { @@ -59,10 +54,11 @@ function make_lexer(keywords) { } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - return [ - /* Ident */1, - id - ]; + return /* Ident */{ + 0: id, + length: 1, + tag: 1 + }; } else { throw exn; @@ -77,7 +73,6 @@ function make_lexer(keywords) { catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { throw [ - 0, Stream.$$Error, "Illegal character " + s ]; @@ -91,7 +86,7 @@ function make_lexer(keywords) { while(true) { var match = Stream.peek(strm__); if (match) { - var c = match[1]; + var c = match[0]; var exit = 0; if (c < 124) { var switcher = c - 65; @@ -112,13 +107,11 @@ function make_lexer(keywords) { case 34 : Stream.junk(strm__); reset_buffer(/* () */0); - return [ - /* Some */0, - [ - /* String */4, - string(strm__) - ] - ]; + return /* Some */[/* String */{ + 0: string(strm__), + length: 1, + tag: 4 + }]; case 39 : Stream.junk(strm__); var c$1; @@ -128,7 +121,6 @@ function make_lexer(keywords) { catch (exn){ if (exn === Stream.Failure) { throw [ - 0, Stream.$$Error, "" ]; @@ -139,27 +131,23 @@ function make_lexer(keywords) { } var match$1 = Stream.peek(strm__); if (match$1) { - if (match$1[1] !== 39) { + if (match$1[0] !== 39) { throw [ - 0, Stream.$$Error, "" ]; } else { Stream.junk(strm__); - return [ - /* Some */0, - [ - /* Char */5, - c$1 - ] - ]; + return /* Some */[/* Char */{ + 0: c$1, + length: 1, + tag: 5 + }]; } } else { throw [ - 0, Stream.$$Error, "" ]; @@ -170,11 +158,8 @@ function make_lexer(keywords) { var strm__$1 = strm__; var match$2 = Stream.peek(strm__$1); if (match$2) { - if (match$2[1] !== 42) { - return [ - /* Some */0, - keyword_or_error(/* "(" */40) - ]; + if (match$2[0] !== 42) { + return /* Some */[keyword_or_error(/* "(" */40)]; } else { Stream.junk(strm__$1); @@ -183,17 +168,14 @@ function make_lexer(keywords) { } } else { - return [ - /* Some */0, - keyword_or_error(/* "(" */40) - ]; + return /* Some */[keyword_or_error(/* "(" */40)]; } case 45 : Stream.junk(strm__); var strm__$2 = strm__; var match$3 = Stream.peek(strm__$2); if (match$3) { - var c$2 = match$3[1]; + var c$2 = match$3[0]; if (c$2 > 57 || c$2 < 48) { reset_buffer(/* () */0); store(/* "-" */45); @@ -311,10 +293,7 @@ function make_lexer(keywords) { switch (exit) { case 1 : Stream.junk(strm__); - return [ - /* Some */0, - keyword_or_error(c) - ]; + return /* Some */[keyword_or_error(c)]; case 2 : Stream.junk(strm__); reset_buffer(/* () */0); @@ -323,7 +302,7 @@ function make_lexer(keywords) { while(true) { var match$4 = Stream.peek(strm__$3); if (match$4) { - var c$3 = match$4[1]; + var c$3 = match$4[0]; var exit$1 = 0; if (c$3 >= 91) { var switcher$2 = c$3 - 95; @@ -332,20 +311,14 @@ function make_lexer(keywords) { exit$1 = 1; } else { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } } else if (switcher$2 !== 1) { exit$1 = 1; } else { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } } else if (c$3 >= 48) { @@ -353,17 +326,11 @@ function make_lexer(keywords) { exit$1 = 1; } else { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } } else if (c$3 !== 39) { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } else { exit$1 = 1; @@ -377,10 +344,7 @@ function make_lexer(keywords) { } else { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } }; case 3 : @@ -405,26 +369,20 @@ function make_lexer(keywords) { while(true) { var match = Stream.peek(strm__); if (match) { - var c = match[1]; + var c = match[0]; var exit = 0; if (c >= 94) { var switcher = c - 95; if (switcher > 30 || switcher < 0) { if (switcher >= 32) { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } else { exit = 1; } } else if (switcher !== 29) { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } else { exit = 1; @@ -432,10 +390,7 @@ function make_lexer(keywords) { } else if (c >= 65) { if (c !== 92) { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } else { exit = 1; @@ -460,10 +415,7 @@ function make_lexer(keywords) { case 23 : case 24 : case 26 : - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; case 0 : case 2 : case 3 : @@ -485,10 +437,7 @@ function make_lexer(keywords) { } } else { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } if (exit === 1) { Stream.junk(strm__); @@ -499,10 +448,7 @@ function make_lexer(keywords) { } else { - return [ - /* Some */0, - ident_or_keyword(get_string(/* () */0)) - ]; + return /* Some */[ident_or_keyword(get_string(/* () */0))]; } }; }; @@ -511,7 +457,7 @@ function make_lexer(keywords) { var match = Stream.peek(strm__); var exit = 0; if (match) { - var c = match[1]; + var c = match[0]; if (c >= 58) { if (c !== 69) { if (c !== 101) { @@ -548,7 +494,7 @@ function make_lexer(keywords) { var match$1 = Stream.peek(strm__$1); var exit$1 = 0; if (match$1) { - var c$1 = match$1[1]; + var c$1 = match$1[0]; var switcher = c$1 - 69; if (switcher > 32 || switcher < 0) { if ((switcher + 21 >>> 0) > 9) { @@ -574,13 +520,11 @@ function make_lexer(keywords) { exit$1 = 1; } if (exit$1 === 1) { - return [ - /* Some */0, - [ - /* Float */3, - Caml_format.caml_float_of_string(get_string(/* () */0)) - ] - ]; + return /* Some */[/* Float */{ + 0: Caml_format.caml_float_of_string(get_string(/* () */0)), + length: 1, + tag: 3 + }]; } }; @@ -590,13 +534,11 @@ function make_lexer(keywords) { exit = 1; } if (exit === 1) { - return [ - /* Some */0, - [ - /* Int */2, - Caml_format.caml_int_of_string(get_string(/* () */0)) - ] - ]; + return /* Some */[/* Int */{ + 0: Caml_format.caml_int_of_string(get_string(/* () */0)), + length: 1, + tag: 2 + }]; } }; @@ -604,7 +546,7 @@ function make_lexer(keywords) { var exponent_part = function (strm__) { var match = Stream.peek(strm__); if (match) { - var c = match[1]; + var c = match[0]; if (c !== 43) { if (c !== 45) { return end_exponent_part(strm__); @@ -629,15 +571,13 @@ function make_lexer(keywords) { while(true) { var match = Stream.peek(strm__); if (match) { - var c = match[1]; + var c = match[0]; if (c > 57 || c < 48) { - return [ - /* Some */0, - [ - /* Float */3, - Caml_format.caml_float_of_string(get_string(/* () */0)) - ] - ]; + return /* Some */[/* Float */{ + 0: Caml_format.caml_float_of_string(get_string(/* () */0)), + length: 1, + tag: 3 + }]; } else { Stream.junk(strm__); @@ -647,13 +587,11 @@ function make_lexer(keywords) { } } else { - return [ - /* Some */0, - [ - /* Float */3, - Caml_format.caml_float_of_string(get_string(/* () */0)) - ] - ]; + return /* Some */[/* Float */{ + 0: Caml_format.caml_float_of_string(get_string(/* () */0)), + length: 1, + tag: 3 + }]; } }; }; @@ -661,7 +599,7 @@ function make_lexer(keywords) { while(true) { var match = Stream.peek(strm__); if (match) { - var c = match[1]; + var c = match[0]; if (c !== 34) { if (c !== 92) { Stream.junk(strm__); @@ -678,7 +616,6 @@ function make_lexer(keywords) { catch (exn){ if (exn === Stream.Failure) { throw [ - 0, Stream.$$Error, "" ]; @@ -705,7 +642,7 @@ function make_lexer(keywords) { var $$char = function (strm__) { var match = Stream.peek(strm__); if (match) { - var c = match[1]; + var c = match[0]; if (c !== 92) { Stream.junk(strm__); return c; @@ -718,7 +655,6 @@ function make_lexer(keywords) { catch (exn){ if (exn === Stream.Failure) { throw [ - 0, Stream.$$Error, "" ]; @@ -736,7 +672,7 @@ function make_lexer(keywords) { var $$escape = function (strm__) { var match = Stream.peek(strm__); if (match) { - var c1 = match[1]; + var c1 = match[0]; if (c1 >= 58) { var switcher = c1 - 110; if (switcher > 6 || switcher < 0) { @@ -768,10 +704,9 @@ function make_lexer(keywords) { Stream.junk(strm__); var match$1 = Stream.peek(strm__); if (match$1) { - var c2 = match$1[1]; + var c2 = match$1[0]; if (c2 > 57 || c2 < 48) { throw [ - 0, Stream.$$Error, "" ]; @@ -780,10 +715,9 @@ function make_lexer(keywords) { Stream.junk(strm__); var match$2 = Stream.peek(strm__); if (match$2) { - var c3 = match$2[1]; + var c3 = match$2[0]; if (c3 > 57 || c3 < 48) { throw [ - 0, Stream.$$Error, "" ]; @@ -795,7 +729,6 @@ function make_lexer(keywords) { } else { throw [ - 0, Stream.$$Error, "" ]; @@ -804,7 +737,6 @@ function make_lexer(keywords) { } else { throw [ - 0, Stream.$$Error, "" ]; @@ -823,7 +755,7 @@ function make_lexer(keywords) { while(true) { var match = Stream.peek(strm__); if (match) { - var switcher = match[1] - 40; + var switcher = match[0] - 40; if (switcher > 2 || switcher < 0) { Stream.junk(strm__); continue ; @@ -836,7 +768,7 @@ function make_lexer(keywords) { var strm__$1 = strm__; var match$1 = Stream.peek(strm__$1); if (match$1) { - if (match$1[1] !== 42) { + if (match$1[0] !== 42) { Stream.junk(strm__$1); return comment(strm__$1); } @@ -858,7 +790,7 @@ function make_lexer(keywords) { while(true) { var match$2 = Stream.peek(strm__$2); if (match$2) { - var c = match$2[1]; + var c = match$2[0]; if (c !== 41) { if (c !== 42) { Stream.junk(strm__$2); diff --git a/jscomp/stdlib/hashtbl.js b/jscomp/stdlib/hashtbl.js index 45040b5eca..033c84346f 100644 --- a/jscomp/stdlib/hashtbl.js +++ b/jscomp/stdlib/hashtbl.js @@ -2,7 +2,7 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); +var Caml_obj = require("../runtime/caml_obj"); var CamlinternalLazy = require("./camlinternalLazy"); var Caml_sys = require("../runtime/caml_sys"); var Pervasives = require("./pervasives"); @@ -52,22 +52,20 @@ catch (exn){ var randomized_default = $$String.contains(params, /* "R" */82); -var randomized = [ - 0, - randomized_default -]; +var randomized = [randomized_default]; function randomize() { - randomized[1] = /* true */1; + randomized[0] = /* true */1; return /* () */0; } -var prng = [ - 246, - function () { - return Caml_curry.app1(Random.State[2], /* () */0); - } -]; +var prng = { + 0: function () { + return Caml_curry.app1(Random.State[1], /* () */0); + }, + length: 1, + tag: 246 +}; function power_2_above(_x, n) { while(true) { @@ -87,20 +85,19 @@ function power_2_above(_x, n) { } function create($staropt$star, initial_size) { - var random = $staropt$star ? $staropt$star[1] : randomized[1]; + var random = $staropt$star ? $staropt$star[0] : randomized[0]; var s = power_2_above(16, initial_size); var seed; if (random) { - var tag = Caml_obj_runtime.caml_obj_tag(prng); - seed = Caml_curry.app1(Random.State[4], tag === 250 ? prng[1] : ( + var tag = prng.tag | 0; + seed = Caml_curry.app1(Random.State[3], tag === 250 ? prng[0] : ( tag === 246 ? CamlinternalLazy.force_lazy_block(prng) : prng )); } else { seed = 0; } - return [ - /* record */0, + return /* record */[ 0, Caml_array.caml_make_vect(s, /* Empty */0), seed, @@ -109,58 +106,58 @@ function create($staropt$star, initial_size) { } function clear(h) { - h[1] = 0; - var len = h[2].length; + h[0] = 0; + var len = h[1].length; for(var i = 0 ,i_finish = len - 1; i<= i_finish; ++i){ - h[2][i] = /* Empty */0; + h[1][i] = /* Empty */0; } return /* () */0; } function reset(h) { - var len = h[2].length; - if (h.length < 4 || len === h[4]) { + var len = h[1].length; + if (h.length < 4 || len === h[3]) { return clear(h); } else { - h[1] = 0; - h[2] = Caml_array.caml_make_vect(h[4], /* Empty */0); + h[0] = 0; + h[1] = Caml_array.caml_make_vect(h[3], /* Empty */0); return /* () */0; } } function copy(h) { - return [ - /* record */0, - h[1], - $$Array.copy(h[2]), - h[3], - h[4] + return /* record */[ + h[0], + $$Array.copy(h[1]), + h[2], + h[3] ]; } function length(h) { - return h[1]; + return h[0]; } function resize(indexfun, h) { - var odata = h[2]; + var odata = h[1]; var osize = odata.length; var nsize = osize * 2; if (nsize < Sys.max_array_length) { var ndata = Caml_array.caml_make_vect(nsize, /* Empty */0); - h[2] = ndata; + h[1] = ndata; var insert_bucket = function (param) { if (param) { - var key = param[1]; - insert_bucket(param[3]); + var key = param[0]; + insert_bucket(param[2]); var nidx = Caml_curry.app2(indexfun, h, key); - ndata[nidx] = [ - /* Cons */0, - key, - param[2], - ndata[nidx] - ]; + ndata[nidx] = /* Cons */{ + 0: key, + 1: param[1], + 2: ndata[nidx], + length: 3, + tag: 0 + }; return /* () */0; } else { @@ -179,25 +176,26 @@ function resize(indexfun, h) { function key_index(h, key) { if (h.length >= 3) { - return Caml_primitive.caml_hash(10, 100, h[3], key) & h[2].length - 1; + return Caml_primitive.caml_hash(10, 100, h[2], key) & h[1].length - 1; } else { - return Caml_primitive.caml_hash_univ_param(10, 100, key) % h[2].length; + return Caml_primitive.caml_hash_univ_param(10, 100, key) % h[1].length; } } function add(h, key, info) { var i = key_index(h, key); - var bucket_003 = h[2][i]; - var bucket = [ - /* Cons */0, - key, - info, - bucket_003 - ]; - h[2][i] = bucket; - ++ h[1]; - if (h[1] > (h[2].length << 1)) { + var bucket_002 = h[1][i]; + var bucket = /* Cons */{ + 0: key, + 1: info, + 2: bucket_002, + length: 3, + tag: 0 + }; + h[1][i] = bucket; + ++ h[0]; + if (h[0] > (h[1].length << 1)) { return resize(key_index, h); } else { @@ -208,18 +206,19 @@ function add(h, key, info) { function remove(h, key) { var remove_bucket = function (param) { if (param) { - var next = param[3]; - var k = param[1]; - if (Caml_primitive.caml_compare(k, key)) { - return [ - /* Cons */0, - k, - param[2], - remove_bucket(next) - ]; + var next = param[2]; + var k = param[0]; + if (Caml_obj.caml_compare(k, key)) { + return /* Cons */{ + 0: k, + 1: param[1], + 2: remove_bucket(next), + length: 3, + tag: 0 + }; } else { - -- h[1]; + -- h[0]; return next; } } @@ -228,32 +227,32 @@ function remove(h, key) { } }; var i = key_index(h, key); - h[2][i] = remove_bucket(h[2][i]); + h[1][i] = remove_bucket(h[1][i]); return /* () */0; } function find(h, key) { - var match = h[2][key_index(h, key)]; + var match = h[1][key_index(h, key)]; if (match) { - var rest1 = match[3]; - if (Caml_primitive.caml_compare(key, match[1])) { + var rest1 = match[2]; + if (Caml_obj.caml_compare(key, match[0])) { if (rest1) { - var rest2 = rest1[3]; - if (Caml_primitive.caml_compare(key, rest1[1])) { + var rest2 = rest1[2]; + if (Caml_obj.caml_compare(key, rest1[0])) { if (rest2) { - if (Caml_primitive.caml_compare(key, rest2[1])) { + if (Caml_obj.caml_compare(key, rest2[0])) { var key$1 = key; - var _param = rest2[3]; + var _param = rest2[2]; while(true) { var param = _param; if (param) { - if (Caml_primitive.caml_compare(key$1, param[1])) { - _param = param[3]; + if (Caml_obj.caml_compare(key$1, param[0])) { + _param = param[2]; continue ; } else { - return param[2]; + return param[1]; } } else { @@ -262,7 +261,7 @@ function find(h, key) { }; } else { - return rest2[2]; + return rest2[1]; } } else { @@ -270,7 +269,7 @@ function find(h, key) { } } else { - return rest1[2]; + return rest1[1]; } } else { @@ -278,7 +277,7 @@ function find(h, key) { } } else { - return match[2]; + return match[1]; } } else { @@ -291,16 +290,15 @@ function find_all(h, key) { while(true) { var param = _param; if (param) { - var rest = param[3]; - if (Caml_primitive.caml_compare(param[1], key)) { + var rest = param[2]; + if (Caml_obj.caml_compare(param[0], key)) { _param = rest; continue ; } else { - return [ - /* :: */0, - param[2], + return /* :: */[ + param[1], find_in_bucket(rest) ]; } @@ -310,29 +308,31 @@ function find_all(h, key) { } }; }; - return find_in_bucket(h[2][key_index(h, key)]); + return find_in_bucket(h[1][key_index(h, key)]); } function replace(h, key, info) { var replace_bucket = function (param) { if (param) { - var next = param[3]; - var k = param[1]; - if (Caml_primitive.caml_compare(k, key)) { - return [ - /* Cons */0, - k, - param[2], - replace_bucket(next) - ]; + var next = param[2]; + var k = param[0]; + if (Caml_obj.caml_compare(k, key)) { + return /* Cons */{ + 0: k, + 1: param[1], + 2: replace_bucket(next), + length: 3, + tag: 0 + }; } else { - return [ - /* Cons */0, - key, - info, - next - ]; + return /* Cons */{ + 0: key, + 1: info, + 2: next, + length: 3, + tag: 0 + }; } } else { @@ -340,21 +340,22 @@ function replace(h, key, info) { } }; var i = key_index(h, key); - var l = h[2][i]; + var l = h[1][i]; try { - h[2][i] = replace_bucket(l); + h[1][i] = replace_bucket(l); return /* () */0; } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - h[2][i] = [ - /* Cons */0, - key, - info, - l - ]; - ++ h[1]; - if (h[1] > (h[2].length << 1)) { + h[1][i] = /* Cons */{ + 0: key, + 1: info, + 2: l, + length: 3, + tag: 0 + }; + ++ h[0]; + if (h[0] > (h[1].length << 1)) { return resize(key_index, h); } else { @@ -368,12 +369,12 @@ function replace(h, key, info) { } function mem(h, key) { - var _param = h[2][key_index(h, key)]; + var _param = h[1][key_index(h, key)]; while(true) { var param = _param; if (param) { - if (Caml_primitive.caml_compare(param[1], key)) { - _param = param[3]; + if (Caml_obj.caml_compare(param[0], key)) { + _param = param[2]; continue ; } @@ -392,8 +393,8 @@ function iter(f, h) { while(true) { var param = _param; if (param) { - Caml_curry.app2(f, param[1], param[2]); - _param = param[3]; + Caml_curry.app2(f, param[0], param[1]); + _param = param[2]; continue ; } @@ -402,7 +403,7 @@ function iter(f, h) { } }; }; - var d = h[2]; + var d = h[1]; for(var i = 0 ,i_finish = d.length - 1; i<= i_finish; ++i){ do_bucket(d[i]); } @@ -415,8 +416,8 @@ function fold(f, h, init) { var accu = _accu; var b = _b; if (b) { - _accu = Caml_curry.app3(f, b[1], b[2], accu); - _b = b[3]; + _accu = Caml_curry.app3(f, b[0], b[1], accu); + _b = b[2]; continue ; } @@ -425,7 +426,7 @@ function fold(f, h, init) { } }; }; - var d = h[2]; + var d = h[1]; var accu = init; for(var i = 0 ,i_finish = d.length - 1; i<= i_finish; ++i){ accu = do_bucket(d[i], accu); @@ -438,7 +439,7 @@ function bucket_length(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[3]; + _param = param[2]; _accu = accu + 1; continue ; @@ -452,17 +453,16 @@ function bucket_length(_accu, _param) { function stats(h) { var mbl = $$Array.fold_left(function (m, b) { return Pervasives.max(m, bucket_length(0, b)); - }, 0, h[2]); + }, 0, h[1]); var histo = Caml_array.caml_make_vect(mbl + 1, 0); $$Array.iter(function (b) { var l = bucket_length(0, b); histo[l] = histo[l] + 1; return /* () */0; - }, h[2]); - return [ - /* record */0, - h[1], - h[2].length, + }, h[1]); + return /* record */[ + h[0], + h[1].length, mbl, histo ]; @@ -470,20 +470,21 @@ function stats(h) { function MakeSeeded(H) { var key_index = function (h, key) { - return Caml_curry.app2(H[2], h[3], key) & h[2].length - 1; + return Caml_curry.app2(H[1], h[2], key) & h[1].length - 1; }; var add = function (h, key, info) { var i = key_index(h, key); - var bucket_003 = h[2][i]; - var bucket = [ - /* Cons */0, - key, - info, - bucket_003 - ]; - h[2][i] = bucket; - ++ h[1]; - if (h[1] > (h[2].length << 1)) { + var bucket_002 = h[1][i]; + var bucket = /* Cons */{ + 0: key, + 1: info, + 2: bucket_002, + length: 3, + tag: 0 + }; + h[1][i] = bucket; + ++ h[0]; + if (h[0] > (h[1].length << 1)) { return resize(key_index, h); } else { @@ -493,19 +494,20 @@ function MakeSeeded(H) { var remove = function (h, key) { var remove_bucket = function (param) { if (param) { - var next = param[3]; - var k = param[1]; - if (Caml_curry.app2(H[1], k, key)) { - -- h[1]; + var next = param[2]; + var k = param[0]; + if (Caml_curry.app2(H[0], k, key)) { + -- h[0]; return next; } else { - return [ - /* Cons */0, - k, - param[2], - remove_bucket(next) - ]; + return /* Cons */{ + 0: k, + 1: param[1], + 2: remove_bucket(next), + length: 3, + tag: 0 + }; } } else { @@ -513,36 +515,36 @@ function MakeSeeded(H) { } }; var i = key_index(h, key); - h[2][i] = remove_bucket(h[2][i]); + h[1][i] = remove_bucket(h[1][i]); return /* () */0; }; var find = function (h, key) { - var match = h[2][key_index(h, key)]; + var match = h[1][key_index(h, key)]; if (match) { - var rest1 = match[3]; - if (Caml_curry.app2(H[1], key, match[1])) { - return match[2]; + var rest1 = match[2]; + if (Caml_curry.app2(H[0], key, match[0])) { + return match[1]; } else if (rest1) { - var rest2 = rest1[3]; - if (Caml_curry.app2(H[1], key, rest1[1])) { - return rest1[2]; + var rest2 = rest1[2]; + if (Caml_curry.app2(H[0], key, rest1[0])) { + return rest1[1]; } else if (rest2) { - if (Caml_curry.app2(H[1], key, rest2[1])) { - return rest2[2]; + if (Caml_curry.app2(H[0], key, rest2[0])) { + return rest2[1]; } else { var key$1 = key; - var _param = rest2[3]; + var _param = rest2[2]; while(true) { var param = _param; if (param) { - if (Caml_curry.app2(H[1], key$1, param[1])) { - return param[2]; + if (Caml_curry.app2(H[0], key$1, param[0])) { + return param[1]; } else { - _param = param[3]; + _param = param[2]; continue ; } @@ -570,11 +572,10 @@ function MakeSeeded(H) { while(true) { var param = _param; if (param) { - var rest = param[3]; - if (Caml_curry.app2(H[1], param[1], key)) { - return [ - /* :: */0, - param[2], + var rest = param[2]; + if (Caml_curry.app2(H[0], param[0], key)) { + return /* :: */[ + param[1], find_in_bucket(rest) ]; } @@ -589,28 +590,30 @@ function MakeSeeded(H) { } }; }; - return find_in_bucket(h[2][key_index(h, key)]); + return find_in_bucket(h[1][key_index(h, key)]); }; var replace = function (h, key, info) { var replace_bucket = function (param) { if (param) { - var next = param[3]; - var k = param[1]; - if (Caml_curry.app2(H[1], k, key)) { - return [ - /* Cons */0, - key, - info, - next - ]; + var next = param[2]; + var k = param[0]; + if (Caml_curry.app2(H[0], k, key)) { + return /* Cons */{ + 0: key, + 1: info, + 2: next, + length: 3, + tag: 0 + }; } else { - return [ - /* Cons */0, - k, - param[2], - replace_bucket(next) - ]; + return /* Cons */{ + 0: k, + 1: param[1], + 2: replace_bucket(next), + length: 3, + tag: 0 + }; } } else { @@ -618,21 +621,22 @@ function MakeSeeded(H) { } }; var i = key_index(h, key); - var l = h[2][i]; + var l = h[1][i]; try { - h[2][i] = replace_bucket(l); + h[1][i] = replace_bucket(l); return /* () */0; } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - h[2][i] = [ - /* Cons */0, - key, - info, - l - ]; - ++ h[1]; - if (h[1] > (h[2].length << 1)) { + h[1][i] = /* Cons */{ + 0: key, + 1: info, + 2: l, + length: 3, + tag: 0 + }; + ++ h[0]; + if (h[0] > (h[1].length << 1)) { return resize(key_index, h); } else { @@ -645,15 +649,15 @@ function MakeSeeded(H) { } }; var mem = function (h, key) { - var _param = h[2][key_index(h, key)]; + var _param = h[1][key_index(h, key)]; while(true) { var param = _param; if (param) { - if (Caml_curry.app2(H[1], param[1], key)) { + if (Caml_curry.app2(H[0], param[0], key)) { return /* true */1; } else { - _param = param[3]; + _param = param[2]; continue ; } @@ -664,7 +668,6 @@ function MakeSeeded(H) { }; }; return [ - 0, create, clear, reset, @@ -683,22 +686,23 @@ function MakeSeeded(H) { } function Make(H) { - var equal = H[1]; + var equal = H[0]; var key_index = function (h, key) { - return Caml_curry.app1(H[2], key) & h[2].length - 1; + return Caml_curry.app1(H[1], key) & h[1].length - 1; }; var add = function (h, key, info) { var i = key_index(h, key); - var bucket_003 = h[2][i]; - var bucket = [ - /* Cons */0, - key, - info, - bucket_003 - ]; - h[2][i] = bucket; - ++ h[1]; - if (h[1] > (h[2].length << 1)) { + var bucket_002 = h[1][i]; + var bucket = /* Cons */{ + 0: key, + 1: info, + 2: bucket_002, + length: 3, + tag: 0 + }; + h[1][i] = bucket; + ++ h[0]; + if (h[0] > (h[1].length << 1)) { return resize(key_index, h); } else { @@ -708,19 +712,20 @@ function Make(H) { var remove = function (h, key) { var remove_bucket = function (param) { if (param) { - var next = param[3]; - var k = param[1]; + var next = param[2]; + var k = param[0]; if (Caml_curry.app2(equal, k, key)) { - -- h[1]; + -- h[0]; return next; } else { - return [ - /* Cons */0, - k, - param[2], - remove_bucket(next) - ]; + return /* Cons */{ + 0: k, + 1: param[1], + 2: remove_bucket(next), + length: 3, + tag: 0 + }; } } else { @@ -728,36 +733,36 @@ function Make(H) { } }; var i = key_index(h, key); - h[2][i] = remove_bucket(h[2][i]); + h[1][i] = remove_bucket(h[1][i]); return /* () */0; }; var find = function (h, key) { - var match = h[2][key_index(h, key)]; + var match = h[1][key_index(h, key)]; if (match) { - var rest1 = match[3]; - if (Caml_curry.app2(equal, key, match[1])) { - return match[2]; + var rest1 = match[2]; + if (Caml_curry.app2(equal, key, match[0])) { + return match[1]; } else if (rest1) { - var rest2 = rest1[3]; - if (Caml_curry.app2(equal, key, rest1[1])) { - return rest1[2]; + var rest2 = rest1[2]; + if (Caml_curry.app2(equal, key, rest1[0])) { + return rest1[1]; } else if (rest2) { - if (Caml_curry.app2(equal, key, rest2[1])) { - return rest2[2]; + if (Caml_curry.app2(equal, key, rest2[0])) { + return rest2[1]; } else { var key$1 = key; - var _param = rest2[3]; + var _param = rest2[2]; while(true) { var param = _param; if (param) { - if (Caml_curry.app2(equal, key$1, param[1])) { - return param[2]; + if (Caml_curry.app2(equal, key$1, param[0])) { + return param[1]; } else { - _param = param[3]; + _param = param[2]; continue ; } @@ -785,11 +790,10 @@ function Make(H) { while(true) { var param = _param; if (param) { - var rest = param[3]; - if (Caml_curry.app2(equal, param[1], key)) { - return [ - /* :: */0, - param[2], + var rest = param[2]; + if (Caml_curry.app2(equal, param[0], key)) { + return /* :: */[ + param[1], find_in_bucket(rest) ]; } @@ -804,28 +808,30 @@ function Make(H) { } }; }; - return find_in_bucket(h[2][key_index(h, key)]); + return find_in_bucket(h[1][key_index(h, key)]); }; var replace = function (h, key, info) { var replace_bucket = function (param) { if (param) { - var next = param[3]; - var k = param[1]; + var next = param[2]; + var k = param[0]; if (Caml_curry.app2(equal, k, key)) { - return [ - /* Cons */0, - key, - info, - next - ]; + return /* Cons */{ + 0: key, + 1: info, + 2: next, + length: 3, + tag: 0 + }; } else { - return [ - /* Cons */0, - k, - param[2], - replace_bucket(next) - ]; + return /* Cons */{ + 0: k, + 1: param[1], + 2: replace_bucket(next), + length: 3, + tag: 0 + }; } } else { @@ -833,21 +839,22 @@ function Make(H) { } }; var i = key_index(h, key); - var l = h[2][i]; + var l = h[1][i]; try { - h[2][i] = replace_bucket(l); + h[1][i] = replace_bucket(l); return /* () */0; } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - h[2][i] = [ - /* Cons */0, - key, - info, - l - ]; - ++ h[1]; - if (h[1] > (h[2].length << 1)) { + h[1][i] = /* Cons */{ + 0: key, + 1: info, + 2: l, + length: 3, + tag: 0 + }; + ++ h[0]; + if (h[0] > (h[1].length << 1)) { return resize(key_index, h); } else { @@ -860,15 +867,15 @@ function Make(H) { } }; var mem = function (h, key) { - var _param = h[2][key_index(h, key)]; + var _param = h[1][key_index(h, key)]; while(true) { var param = _param; if (param) { - if (Caml_curry.app2(equal, param[1], key)) { + if (Caml_curry.app2(equal, param[0], key)) { return /* true */1; } else { - _param = param[3]; + _param = param[2]; continue ; } @@ -879,13 +886,9 @@ function Make(H) { }; }; var create$1 = function (sz) { - return create([ - /* Some */0, - /* false */0 - ], sz); + return create(/* Some */[/* false */0], sz); }; return [ - 0, create$1, clear, reset, diff --git a/jscomp/stdlib/int32.js b/jscomp/stdlib/int32.js index 53327c4f43..f6d9125e84 100644 --- a/jscomp/stdlib/int32.js +++ b/jscomp/stdlib/int32.js @@ -1,8 +1,8 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_format = require("../runtime/caml_format"); -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_obj = require("../runtime/caml_obj"); +var Caml_format = require("../runtime/caml_format"); function succ(n) { return n + 1; @@ -30,7 +30,7 @@ function to_string(n) { } function compare(x, y) { - return Caml_primitive.caml_int32_compare(x, y); + return Caml_obj.caml_int32_compare(x, y); } var zero = 0; diff --git a/jscomp/stdlib/lazy.js b/jscomp/stdlib/lazy.js index ef6462d929..7307eb6023 100644 --- a/jscomp/stdlib/lazy.js +++ b/jscomp/stdlib/lazy.js @@ -1,20 +1,24 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); +var Caml_obj = require("../runtime/caml_obj"); var Obj = require("./obj"); var CamlinternalLazy = require("./camlinternalLazy"); function from_fun(f) { - var x = Caml_obj_runtime.caml_obj_block(Obj.lazy_tag, 1); + var x = { + 0: 0, + length: 1, + tag: Obj.lazy_tag + }; x[0] = f; return x; } function from_val(v) { - var t = Caml_obj_runtime.caml_obj_tag(v); + var t = v.tag | 0; if (t === Obj.forward_tag || t === Obj.lazy_tag || t === Obj.double_tag) { - return Caml_obj_runtime.caml_lazy_make_forward(v); + return Caml_obj.caml_lazy_make_forward(v); } else { return v; @@ -22,7 +26,7 @@ function from_val(v) { } function is_val(l) { - return +(Caml_obj_runtime.caml_obj_tag(l) !== Obj.lazy_tag); + return +((l.tag | 0) !== Obj.lazy_tag); } var Undefined = CamlinternalLazy.Undefined; diff --git a/jscomp/stdlib/lexing.js b/jscomp/stdlib/lexing.js index 0d23f1d7ff..a4dc16b41f 100644 --- a/jscomp/stdlib/lexing.js +++ b/jscomp/stdlib/lexing.js @@ -12,14 +12,13 @@ var Caml_string = require("../runtime/caml_string"); function engine(tbl, state, buf) { var result = Caml_lexer.caml_lex_engine(tbl, state, buf); if (result >= 0) { - buf[11] = buf[12]; - var init = buf[12]; - buf[12] = [ - /* record */0, + buf[10] = buf[11]; + var init = buf[11]; + buf[11] = /* record */[ + init[0], init[1], init[2], - init[3], - buf[4] + buf[6] + buf[3] + buf[5] ]; } return result; @@ -28,21 +27,19 @@ function engine(tbl, state, buf) { function new_engine(tbl, state, buf) { var result = Caml_lexer.caml_new_lex_engine(tbl, state, buf); if (result >= 0) { - buf[11] = buf[12]; - var init = buf[12]; - buf[12] = [ - /* record */0, + buf[10] = buf[11]; + var init = buf[11]; + buf[11] = /* record */[ + init[0], init[1], init[2], - init[3], - buf[4] + buf[6] + buf[3] + buf[5] ]; } return result; } -var zero_pos = [ - /* record */0, +var zero_pos = /* record */[ "", 1, 0, @@ -50,38 +47,36 @@ var zero_pos = [ ]; function from_function(f) { - return [ - /* record */0, + return /* record */[ function (param) { var read_fun = f; var aux_buffer = new Array(512); var lexbuf = param; var read = Caml_curry.app2(read_fun, aux_buffer, aux_buffer.length); - var n = read > 0 ? read : (lexbuf[9] = /* true */1, 0); - if (lexbuf[3] + n > lexbuf[2].length) { - if (lexbuf[3] - lexbuf[5] + n <= lexbuf[2].length) { - Bytes.blit(lexbuf[2], lexbuf[5], lexbuf[2], 0, lexbuf[3] - lexbuf[5]); + var n = read > 0 ? read : (lexbuf[8] = /* true */1, 0); + if (lexbuf[2] + n > lexbuf[1].length) { + if (lexbuf[2] - lexbuf[4] + n <= lexbuf[1].length) { + Bytes.blit(lexbuf[1], lexbuf[4], lexbuf[1], 0, lexbuf[2] - lexbuf[4]); } else { - var newlen = Pervasives.min(2 * lexbuf[2].length, Sys.max_string_length); - if (lexbuf[3] - lexbuf[5] + n > newlen) { + var newlen = Pervasives.min(2 * lexbuf[1].length, Sys.max_string_length); + if (lexbuf[2] - lexbuf[4] + n > newlen) { throw [ - 0, Caml_builtin_exceptions.Failure, "Lexing.lex_refill: cannot grow buffer" ]; } var newbuf = Caml_string.caml_create_string(newlen); - Bytes.blit(lexbuf[2], lexbuf[5], newbuf, 0, lexbuf[3] - lexbuf[5]); - lexbuf[2] = newbuf; + Bytes.blit(lexbuf[1], lexbuf[4], newbuf, 0, lexbuf[2] - lexbuf[4]); + lexbuf[1] = newbuf; } - var s = lexbuf[5]; - lexbuf[4] += s; + var s = lexbuf[4]; + lexbuf[3] += s; + lexbuf[5] -= s; + lexbuf[4] = 0; lexbuf[6] -= s; - lexbuf[5] = 0; - lexbuf[7] -= s; - lexbuf[3] -= s; - var t = lexbuf[10]; + lexbuf[2] -= s; + var t = lexbuf[9]; for(var i = 0 ,i_finish = t.length - 1; i<= i_finish; ++i){ var v = t[i]; if (v >= 0) { @@ -90,8 +85,8 @@ function from_function(f) { } } - Bytes.blit(aux_buffer, 0, lexbuf[2], lexbuf[3], n); - lexbuf[3] += n; + Bytes.blit(aux_buffer, 0, lexbuf[1], lexbuf[2], n); + lexbuf[2] += n; return /* () */0; }, new Array(1024), @@ -102,7 +97,7 @@ function from_function(f) { 0, 0, /* false */0, - /* array */[], + /* int array */[], zero_pos, zero_pos ]; @@ -115,10 +110,9 @@ function from_channel(ic) { } function from_string(s) { - return [ - /* record */0, + return /* record */[ function (lexbuf) { - lexbuf[9] = /* true */1; + lexbuf[8] = /* true */1; return /* () */0; }, Bytes.of_string(s), @@ -129,29 +123,26 @@ function from_string(s) { 0, 0, /* true */1, - /* array */[], + /* int array */[], zero_pos, zero_pos ]; } function lexeme(lexbuf) { - var len = lexbuf[6] - lexbuf[5]; - return Bytes.sub_string(lexbuf[2], lexbuf[5], len); + var len = lexbuf[5] - lexbuf[4]; + return Bytes.sub_string(lexbuf[1], lexbuf[4], len); } function sub_lexeme(lexbuf, i1, i2) { var len = i2 - i1; - return Bytes.sub_string(lexbuf[2], i1, len); + return Bytes.sub_string(lexbuf[1], i1, len); } function sub_lexeme_opt(lexbuf, i1, i2) { if (i1 >= 0) { var len = i2 - i1; - return [ - /* Some */0, - Bytes.sub_string(lexbuf[2], i1, len) - ]; + return /* Some */[Bytes.sub_string(lexbuf[1], i1, len)]; } else { return /* None */0; @@ -159,15 +150,12 @@ function sub_lexeme_opt(lexbuf, i1, i2) { } function sub_lexeme_char(lexbuf, i) { - return lexbuf[2][i]; + return lexbuf[1][i]; } function sub_lexeme_char_opt(lexbuf, i) { if (i >= 0) { - return [ - /* Some */0, - lexbuf[2][i] - ]; + return /* Some */[lexbuf[1][i]]; } else { return /* None */0; @@ -175,54 +163,51 @@ function sub_lexeme_char_opt(lexbuf, i) { } function lexeme_char(lexbuf, i) { - return lexbuf[2][lexbuf[5] + i]; + return lexbuf[1][lexbuf[4] + i]; } function lexeme_start(lexbuf) { - return lexbuf[11][4]; + return lexbuf[10][3]; } function lexeme_end(lexbuf) { - return lexbuf[12][4]; + return lexbuf[11][3]; } function lexeme_start_p(lexbuf) { - return lexbuf[11]; + return lexbuf[10]; } function lexeme_end_p(lexbuf) { - return lexbuf[12]; + return lexbuf[11]; } function new_line(lexbuf) { - var lcp = lexbuf[12]; - lexbuf[12] = [ - /* record */0, - lcp[1], - lcp[2] + 1, - lcp[4], - lcp[4] + var lcp = lexbuf[11]; + lexbuf[11] = /* record */[ + lcp[0], + lcp[1] + 1, + lcp[3], + lcp[3] ]; return /* () */0; } function flush_input(lb) { - lb[6] = 0; - lb[4] = 0; - var init = lb[12]; - lb[12] = [ - /* record */0, + lb[5] = 0; + lb[3] = 0; + var init = lb[11]; + lb[11] = /* record */[ + init[0], init[1], init[2], - init[3], 0 ]; - lb[3] = 0; + lb[2] = 0; return /* () */0; } -var dummy_pos = [ - /* record */0, +var dummy_pos = /* record */[ "", 0, 0, diff --git a/jscomp/stdlib/list.js b/jscomp/stdlib/list.js index b2e4caef4a..47b5f5dcda 100644 --- a/jscomp/stdlib/list.js +++ b/jscomp/stdlib/list.js @@ -2,8 +2,8 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("./pervasives"); -var Caml_primitive = require("../runtime/caml_primitive"); var Caml_curry = require("../runtime/caml_curry"); function length(l) { @@ -13,7 +13,7 @@ function length(l) { var param = _param; var len = _len; if (param) { - _param = param[2]; + _param = param[1]; _len = len + 1; continue ; @@ -26,11 +26,10 @@ function length(l) { function hd(param) { if (param) { - return param[1]; + return param[0]; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "hd" ]; @@ -39,11 +38,10 @@ function hd(param) { function tl(param) { if (param) { - return param[2]; + return param[1]; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "tl" ]; @@ -53,7 +51,6 @@ function tl(param) { function nth(l, n) { if (n < 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.nth" ]; @@ -67,17 +64,16 @@ function nth(l, n) { if (l$1) { if (n$1) { _n = n$1 - 1; - _l = l$1[2]; + _l = l$1[1]; continue ; } else { - return l$1[1]; + return l$1[0]; } } else { throw [ - 0, Caml_builtin_exceptions.Failure, "nth" ]; @@ -91,12 +87,11 @@ function rev_append(_l1, _l2) { var l2 = _l2; var l1 = _l1; if (l1) { - _l2 = [ - /* :: */0, - l1[1], + _l2 = /* :: */[ + l1[0], l2 ]; - _l1 = l1[2]; + _l1 = l1[1]; continue ; } @@ -112,7 +107,7 @@ function rev(l) { function flatten(param) { if (param) { - return Pervasives.$at(param[1], flatten(param[2])); + return Pervasives.$at(param[0], flatten(param[1])); } else { return /* [] */0; @@ -121,11 +116,10 @@ function flatten(param) { function map(f, param) { if (param) { - var r = Caml_curry.app1(f, param[1]); - return [ - /* :: */0, + var r = Caml_curry.app1(f, param[0]); + return /* :: */[ r, - map(f, param[2]) + map(f, param[1]) ]; } else { @@ -135,11 +129,10 @@ function map(f, param) { function mapi(i, f, param) { if (param) { - var r = Caml_curry.app2(f, i, param[1]); - return [ - /* :: */0, + var r = Caml_curry.app2(f, i, param[0]); + return /* :: */[ r, - mapi(i + 1, f, param[2]) + mapi(i + 1, f, param[1]) ]; } else { @@ -158,10 +151,9 @@ function rev_map(f, l) { var param = _param; var accu = _accu; if (param) { - _param = param[2]; - _accu = [ - /* :: */0, - Caml_curry.app1(f, param[1]), + _param = param[1]; + _accu = /* :: */[ + Caml_curry.app1(f, param[0]), accu ]; continue ; @@ -177,8 +169,8 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - Caml_curry.app1(f, param[1]); - _param = param[2]; + Caml_curry.app1(f, param[0]); + _param = param[1]; continue ; } @@ -196,8 +188,8 @@ function iteri(f, l) { var param = _param; var i = _i; if (param) { - Caml_curry.app2(f$1, i, param[1]); - _param = param[2]; + Caml_curry.app2(f$1, i, param[0]); + _param = param[1]; _i = i + 1; continue ; @@ -213,8 +205,8 @@ function fold_left(f, _accu, _l) { var l = _l; var accu = _accu; if (l) { - _l = l[2]; - _accu = Caml_curry.app2(f, accu, l[1]); + _l = l[1]; + _accu = Caml_curry.app2(f, accu, l[0]); continue ; } @@ -226,7 +218,7 @@ function fold_left(f, _accu, _l) { function fold_right(f, l, accu) { if (l) { - return Caml_curry.app2(f, l[1], fold_right(f, l[2], accu)); + return Caml_curry.app2(f, l[0], fold_right(f, l[1], accu)); } else { return accu; @@ -236,16 +228,14 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - var r = Caml_curry.app2(f, l1[1], l2[1]); - return [ - /* :: */0, + var r = Caml_curry.app2(f, l1[0], l2[0]); + return /* :: */[ r, - map2(f, l1[2], l2[2]) + map2(f, l1[1], l2[1]) ]; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.map2" ]; @@ -253,7 +243,6 @@ function map2(f, l1, l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.map2" ]; @@ -273,11 +262,10 @@ function rev_map2(f, l1, l2) { var accu = _accu; if (l1$1) { if (l2$1) { - _l2 = l2$1[2]; - _l1 = l1$1[2]; - _accu = [ - /* :: */0, - Caml_curry.app2(f, l1$1[1], l2$1[1]), + _l2 = l2$1[1]; + _l1 = l1$1[1]; + _accu = /* :: */[ + Caml_curry.app2(f, l1$1[0], l2$1[0]), accu ]; continue ; @@ -285,7 +273,6 @@ function rev_map2(f, l1, l2) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.rev_map2" ]; @@ -293,7 +280,6 @@ function rev_map2(f, l1, l2) { } else if (l2$1) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.rev_map2" ]; @@ -310,15 +296,14 @@ function iter2(f, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - Caml_curry.app2(f, l1[1], l2[1]); - _l2 = l2[2]; - _l1 = l1[2]; + Caml_curry.app2(f, l1[0], l2[0]); + _l2 = l2[1]; + _l1 = l1[1]; continue ; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.iter2" ]; @@ -326,7 +311,6 @@ function iter2(f, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.iter2" ]; @@ -344,15 +328,14 @@ function fold_left2(f, _accu, _l1, _l2) { var accu = _accu; if (l1) { if (l2) { - _l2 = l2[2]; - _l1 = l1[2]; - _accu = Caml_curry.app3(f, accu, l1[1], l2[1]); + _l2 = l2[1]; + _l1 = l1[1]; + _accu = Caml_curry.app3(f, accu, l1[0], l2[0]); continue ; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_left2" ]; @@ -360,7 +343,6 @@ function fold_left2(f, _accu, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_left2" ]; @@ -374,11 +356,10 @@ function fold_left2(f, _accu, _l1, _l2) { function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return Caml_curry.app3(f, l1[1], l2[1], fold_right2(f, l1[2], l2[2], accu)); + return Caml_curry.app3(f, l1[0], l2[0], fold_right2(f, l1[1], l2[1], accu)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_right2" ]; @@ -386,7 +367,6 @@ function fold_right2(f, l1, l2, accu) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_right2" ]; @@ -400,8 +380,8 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[1])) { - _param = param[2]; + if (Caml_curry.app1(p, param[0])) { + _param = param[1]; continue ; } @@ -419,11 +399,11 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[1])) { + if (Caml_curry.app1(p, param[0])) { return /* true */1; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -440,9 +420,9 @@ function for_all2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (Caml_curry.app2(p, l1[1], l2[1])) { - _l2 = l2[2]; - _l1 = l1[2]; + if (Caml_curry.app2(p, l1[0], l2[0])) { + _l2 = l2[1]; + _l1 = l1[1]; continue ; } @@ -452,7 +432,6 @@ function for_all2(p, _l1, _l2) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.for_all2" ]; @@ -460,7 +439,6 @@ function for_all2(p, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.for_all2" ]; @@ -477,19 +455,18 @@ function exists2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (Caml_curry.app2(p, l1[1], l2[1])) { + if (Caml_curry.app2(p, l1[0], l2[0])) { return /* true */1; } else { - _l2 = l2[2]; - _l1 = l1[2]; + _l2 = l2[1]; + _l1 = l1[1]; continue ; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.exists2" ]; @@ -497,7 +474,6 @@ function exists2(p, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.exists2" ]; @@ -512,8 +488,8 @@ function mem(x, _param) { while(true) { var param = _param; if (param) { - if (Caml_primitive.caml_compare(param[1], x)) { - _param = param[2]; + if (Caml_obj.caml_compare(param[0], x)) { + _param = param[1]; continue ; } @@ -531,11 +507,11 @@ function memq(x, _param) { while(true) { var param = _param; if (param) { - if (param[1] === x) { + if (param[0] === x) { return /* true */1; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -550,14 +526,14 @@ function assoc(x, _param) { while(true) { var param = _param; if (param) { - var match = param[1]; - if (Caml_primitive.caml_compare(match[1], x)) { - _param = param[2]; + var match = param[0]; + if (Caml_obj.caml_compare(match[0], x)) { + _param = param[1]; continue ; } else { - return match[2]; + return match[1]; } } else { @@ -570,12 +546,12 @@ function assq(x, _param) { while(true) { var param = _param; if (param) { - var match = param[1]; - if (match[1] === x) { - return match[2]; + var match = param[0]; + if (match[0] === x) { + return match[1]; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -590,8 +566,8 @@ function mem_assoc(x, _param) { while(true) { var param = _param; if (param) { - if (Caml_primitive.caml_compare(param[1][1], x)) { - _param = param[2]; + if (Caml_obj.caml_compare(param[0][0], x)) { + _param = param[1]; continue ; } @@ -609,11 +585,11 @@ function mem_assq(x, _param) { while(true) { var param = _param; if (param) { - if (param[1][1] === x) { + if (param[0][0] === x) { return /* true */1; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -626,11 +602,10 @@ function mem_assq(x, _param) { function remove_assoc(x, param) { if (param) { - var l = param[2]; - var pair = param[1]; - if (Caml_primitive.caml_compare(pair[1], x)) { - return [ - /* :: */0, + var l = param[1]; + var pair = param[0]; + if (Caml_obj.caml_compare(pair[0], x)) { + return /* :: */[ pair, remove_assoc(x, l) ]; @@ -646,14 +621,13 @@ function remove_assoc(x, param) { function remove_assq(x, param) { if (param) { - var l = param[2]; - var pair = param[1]; - if (pair[1] === x) { + var l = param[1]; + var pair = param[0]; + if (pair[0] === x) { return l; } else { - return [ - /* :: */0, + return /* :: */[ pair, remove_assq(x, l) ]; @@ -668,12 +642,12 @@ function find(p, _param) { while(true) { var param = _param; if (param) { - var x = param[1]; + var x = param[0]; if (Caml_curry.app1(p, x)) { return x; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -692,12 +666,11 @@ function find_all(p) { var param$1 = _param; var accu = _accu; if (param$1) { - var l = param$1[2]; - var x = param$1[1]; + var l = param$1[1]; + var x = param$1[0]; if (Caml_curry.app1(p, x)) { _param = l; - _accu = [ - /* :: */0, + _accu = /* :: */[ x, accu ]; @@ -726,12 +699,11 @@ function partition(p, l) { var no = _no; var yes = _yes; if (param) { - var l$1 = param[2]; - var x = param[1]; + var l$1 = param[1]; + var x = param[0]; if (Caml_curry.app1(p, x)) { _param = l$1; - _yes = [ - /* :: */0, + _yes = /* :: */[ x, yes ]; @@ -740,8 +712,7 @@ function partition(p, l) { } else { _param = l$1; - _no = [ - /* :: */0, + _no = /* :: */[ x, no ]; @@ -750,8 +721,7 @@ function partition(p, l) { } } else { - return [ - /* tuple */0, + return /* tuple */[ rev_append(yes, /* [] */0), rev_append(no, /* [] */0) ]; @@ -761,25 +731,21 @@ function partition(p, l) { function split(param) { if (param) { - var match = param[1]; - var match$1 = split(param[2]); - return [ - /* tuple */0, - [ - /* :: */0, + var match = param[0]; + var match$1 = split(param[1]); + return /* tuple */[ + /* :: */[ + match[0], + match$1[0] + ], + /* :: */[ match[1], match$1[1] - ], - [ - /* :: */0, - match[2], - match$1[2] ] ]; } else { - return [ - /* tuple */0, + return /* tuple */[ /* [] */0, /* [] */0 ]; @@ -789,19 +755,16 @@ function split(param) { function combine(l1, l2) { if (l1) { if (l2) { - return [ - /* :: */0, - [ - /* tuple */0, - l1[1], - l2[1] + return /* :: */[ + /* tuple */[ + l1[0], + l2[0] ], - combine(l1[2], l2[2]) + combine(l1[1], l2[1]) ]; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.combine" ]; @@ -809,7 +772,6 @@ function combine(l1, l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.combine" ]; @@ -822,20 +784,18 @@ function combine(l1, l2) { function merge(cmp, l1, l2) { if (l1) { if (l2) { - var h2 = l2[1]; - var h1 = l1[1]; + var h2 = l2[0]; + var h1 = l1[0]; if (Caml_curry.app2(cmp, h1, h2) <= 0) { - return [ - /* :: */0, + return /* :: */[ h1, - merge(cmp, l1[2], l2) + merge(cmp, l1[1], l2) ]; } else { - return [ - /* :: */0, + return /* :: */[ h2, - merge(cmp, l1, l2[2]) + merge(cmp, l1, l2[1]) ]; } } @@ -854,17 +814,15 @@ function chop(_k, _l) { var k = _k; if (k) { if (l) { - _l = l[2]; + _l = l[1]; _k = k - 1; continue ; } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "list.ml", 223, 11 @@ -886,23 +844,20 @@ function stable_sort(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; if (Caml_curry.app2(cmp, x1, x2) <= 0) { if (Caml_curry.app2(cmp, x2, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -910,14 +865,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x1, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -925,14 +877,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -941,14 +890,11 @@ function stable_sort(cmp, l) { } } else if (Caml_curry.app2(cmp, x1, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -956,14 +902,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x2, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -971,14 +914,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -999,27 +939,23 @@ function stable_sort(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; if (Caml_curry.app2(cmp, x1$1, x2$1) <= 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1048,25 +984,23 @@ function stable_sort(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var h2 = l2$1[1]; - var h1 = l1[1]; + var h2 = l2$1[0]; + var h1 = l1[0]; if (Caml_curry.app2(cmp, h1, h2) > 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; - _l1 = l1[2]; + _l1 = l1[1]; continue ; } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; - _l2 = l2$1[2]; + _l2 = l2$1[1]; continue ; } @@ -1089,23 +1023,20 @@ function stable_sort(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; if (Caml_curry.app2(cmp, x1, x2) > 0) { if (Caml_curry.app2(cmp, x2, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1113,14 +1044,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x1, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1128,14 +1056,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1144,14 +1069,11 @@ function stable_sort(cmp, l) { } } else if (Caml_curry.app2(cmp, x1, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1159,14 +1081,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x2, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1174,14 +1093,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1202,27 +1118,23 @@ function stable_sort(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; if (Caml_curry.app2(cmp, x1$1, x2$1) > 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1251,25 +1163,23 @@ function stable_sort(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var h2 = l2$1[1]; - var h1 = l1[1]; + var h2 = l2$1[0]; + var h1 = l1[0]; if (Caml_curry.app2(cmp, h1, h2) <= 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; - _l1 = l1[2]; + _l1 = l1[1]; continue ; } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; - _l2 = l2$1[2]; + _l2 = l2$1[1]; continue ; } @@ -1302,27 +1212,24 @@ function sort_uniq(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c < 0) { var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 < 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1333,14 +1240,11 @@ function sort_uniq(cmp, l) { var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 < 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1348,14 +1252,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1364,11 +1265,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1377,11 +1276,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1392,14 +1289,11 @@ function sort_uniq(cmp, l) { var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 < 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1410,14 +1304,11 @@ function sort_uniq(cmp, l) { var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 < 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1425,14 +1316,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1441,11 +1329,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1454,11 +1340,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1470,22 +1354,18 @@ function sort_uniq(cmp, l) { var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 < 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1493,8 +1373,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, /* [] */0 ]; @@ -1514,29 +1393,25 @@ function sort_uniq(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 < 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1544,8 +1419,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1$1, /* [] */0 ]; @@ -1573,15 +1447,14 @@ function sort_uniq(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var t2 = l2$1[2]; - var h2 = l2$1[1]; - var t1 = l1[2]; - var h1 = l1[1]; + var t2 = l2$1[1]; + var h2 = l2$1[0]; + var t1 = l1[1]; + var h1 = l1[0]; var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 > 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; @@ -1590,8 +1463,7 @@ function sort_uniq(cmp, l) { } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; @@ -1601,8 +1473,7 @@ function sort_uniq(cmp, l) { } } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; @@ -1630,27 +1501,24 @@ function sort_uniq(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c > 0) { var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1661,14 +1529,11 @@ function sort_uniq(cmp, l) { var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1676,14 +1541,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1692,11 +1554,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1705,11 +1565,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1720,14 +1578,11 @@ function sort_uniq(cmp, l) { var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1738,14 +1593,11 @@ function sort_uniq(cmp, l) { var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1753,14 +1605,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1769,11 +1618,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1782,11 +1629,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1798,22 +1643,18 @@ function sort_uniq(cmp, l) { var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1821,8 +1662,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, /* [] */0 ]; @@ -1842,29 +1682,25 @@ function sort_uniq(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 > 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1872,8 +1708,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1$1, /* [] */0 ]; @@ -1901,15 +1736,14 @@ function sort_uniq(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var t2 = l2$1[2]; - var h2 = l2$1[1]; - var t1 = l1[2]; - var h1 = l1[1]; + var t2 = l2$1[1]; + var h2 = l2$1[0]; + var t1 = l1[1]; + var h1 = l1[0]; var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 < 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; @@ -1918,8 +1752,7 @@ function sort_uniq(cmp, l) { } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; @@ -1929,8 +1762,7 @@ function sort_uniq(cmp, l) { } } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; diff --git a/jscomp/stdlib/map.js b/jscomp/stdlib/map.js index a53dbb57ef..80253857f6 100644 --- a/jscomp/stdlib/map.js +++ b/jscomp/stdlib/map.js @@ -7,7 +7,7 @@ var Caml_curry = require("../runtime/caml_curry"); function Make(funarg) { var height = function (param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -16,43 +16,44 @@ function Make(funarg) { var create = function (l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; }; var singleton = function (x, d) { - return [ - /* Node */0, - /* Empty */0, - x, - d, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: d, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; }; var bal = function (l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -60,7 +61,6 @@ function Make(funarg) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -68,19 +68,18 @@ function Make(funarg) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -88,21 +87,21 @@ function Make(funarg) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } }; var is_empty = function (param) { @@ -115,11 +114,11 @@ function Make(funarg) { }; var add = function (x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_curry.app2(funarg[1], x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(funarg[0], x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -129,39 +128,41 @@ function Make(funarg) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } }; var find = function (x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_curry.app2(funarg[1], x, param[2]); + var c = Caml_curry.app2(funarg[0], x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -173,9 +174,9 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var c = Caml_curry.app2(funarg[1], x, param[2]); + var c = Caml_curry.app2(funarg[0], x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } @@ -192,17 +193,16 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -215,17 +215,16 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var r = param[4]; + var r = param[3]; if (r) { _param = r; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -236,17 +235,16 @@ function Make(funarg) { }; var remove_min_binding = function (param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal(remove_min_binding(l), param[2], param[3], param[4]); + return bal(remove_min_binding(l), param[1], param[2], param[3]); } else { - return param[4]; + return param[3]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.remove_min_elt" ]; @@ -254,11 +252,11 @@ function Make(funarg) { }; var remove = function (x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_curry.app2(funarg[1], x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(funarg[0], x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, d, r); @@ -273,7 +271,7 @@ function Make(funarg) { if (t1) { if (t2) { var match = min_binding(t2); - return bal(t1, match[1], match[2], remove_min_binding(t2)); + return bal(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -292,9 +290,9 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - iter(f, param[1]); - Caml_curry.app2(f, param[2], param[3]); - _param = param[4]; + iter(f, param[0]); + Caml_curry.app2(f, param[1], param[2]); + _param = param[3]; continue ; } @@ -305,17 +303,18 @@ function Make(funarg) { }; var map = function (f, param) { if (param) { - var l$prime = map(f, param[1]); - var d$prime = Caml_curry.app1(f, param[3]); - var r$prime = map(f, param[4]); - return [ - /* Node */0, - l$prime, - param[2], - d$prime, - r$prime, - param[5] - ]; + var l$prime = map(f, param[0]); + var d$prime = Caml_curry.app1(f, param[2]); + var r$prime = map(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: param[1], + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -323,18 +322,19 @@ function Make(funarg) { }; var mapi = function (f, param) { if (param) { - var v = param[2]; - var l$prime = mapi(f, param[1]); - var d$prime = Caml_curry.app2(f, v, param[3]); - var r$prime = mapi(f, param[4]); - return [ - /* Node */0, - l$prime, - v, - d$prime, - r$prime, - param[5] - ]; + var v = param[1]; + var l$prime = mapi(f, param[0]); + var d$prime = Caml_curry.app2(f, v, param[2]); + var r$prime = mapi(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: v, + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -345,8 +345,8 @@ function Make(funarg) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold(f, m[0], accu)); + _m = m[3]; continue ; } @@ -359,9 +359,9 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { - if (for_all(p, param[1])) { - _param = param[4]; + if (Caml_curry.app2(p, param[1], param[2])) { + if (for_all(p, param[0])) { + _param = param[3]; continue ; } @@ -382,14 +382,14 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { + if (Caml_curry.app2(p, param[1], param[2])) { return /* true */1; } - else if (exists(p, param[1])) { + else if (exists(p, param[0])) { return /* true */1; } else { - _param = param[4]; + _param = param[3]; continue ; } @@ -401,7 +401,7 @@ function Make(funarg) { }; var add_min_binding = function (k, v, param) { if (param) { - return bal(add_min_binding(k, v, param[1]), param[2], param[3], param[4]); + return bal(add_min_binding(k, v, param[0]), param[1], param[2], param[3]); } else { return singleton(k, v); @@ -409,7 +409,7 @@ function Make(funarg) { }; var add_max_binding = function (k, v, param) { if (param) { - return bal(param[1], param[2], param[3], add_max_binding(k, v, param[4])); + return bal(param[0], param[1], param[2], add_max_binding(k, v, param[3])); } else { return singleton(k, v); @@ -418,13 +418,13 @@ function Make(funarg) { var join = function (l, v, d, r) { if (l) { if (r) { - var rh = r[5]; - var lh = l[5]; + var rh = r[4]; + var lh = l[4]; if (lh > rh + 2) { - return bal(l[1], l[2], l[3], join(l[4], v, d, r)); + return bal(l[0], l[1], l[2], join(l[3], v, d, r)); } else if (rh > lh + 2) { - return bal(join(l, v, d, r[1]), r[2], r[3], r[4]); + return bal(join(l, v, d, r[0]), r[1], r[2], r[3]); } else { return create(l, v, d, r); @@ -442,7 +442,7 @@ function Make(funarg) { if (t1) { if (t2) { var match = min_binding(t2); - return join(t1, match[1], match[2], remove_min_binding(t2)); + return join(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -454,7 +454,7 @@ function Make(funarg) { }; var concat_or_join = function (t1, v, d, t2) { if (d) { - return join(t1, v, d[1], t2); + return join(t1, v, d[0], t2); } else { return concat(t1, t2); @@ -462,46 +462,39 @@ function Make(funarg) { }; var split = function (x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_curry.app2(funarg[1], x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(funarg[0], x, v); if (c) { if (c < 0) { var match = split(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join(match[3], v, d, r) + join(match[2], v, d, r) ]; } else { var match$1 = split(x, r); - return [ - /* tuple */0, - join(l, v, d, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, - [ - /* Some */0, - d - ], + /* Some */[d], r ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* None */0, /* Empty */0 @@ -511,13 +504,10 @@ function Make(funarg) { var merge = function (f, s1, s2) { var exit = 0; if (s1) { - var v1 = s1[2]; - if (s1[5] >= height(s2)) { + var v1 = s1[1]; + if (s1[4] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, Caml_curry.app3(f, v1, [ - /* Some */0, - s1[3] - ], match[2]), merge(f, s1[4], match[3])); + return concat_or_join(merge(f, s1[0], match[0]), v1, Caml_curry.app3(f, v1, /* Some */[s1[2]], match[1]), merge(f, s1[3], match[2])); } else { exit = 1; @@ -531,19 +521,14 @@ function Make(funarg) { } if (exit === 1) { if (s2) { - var v2 = s2[2]; + var v2 = s2[1]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, Caml_curry.app3(f, v2, match$1[2], [ - /* Some */0, - s2[3] - ]), merge(f, match$1[3], s2[4])); + return concat_or_join(merge(f, match$1[0], s2[0]), v2, Caml_curry.app3(f, v2, match$1[1], /* Some */[s2[2]]), merge(f, match$1[2], s2[3])); } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map.ml", 270, 10 @@ -555,11 +540,11 @@ function Make(funarg) { }; var filter = function (p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var l$prime = filter(p, param[1]); + var d = param[2]; + var v = param[1]; + var l$prime = filter(p, param[0]); var pvd = Caml_curry.app2(p, v, d); - var r$prime = filter(p, param[4]); + var r$prime = filter(p, param[3]); if (pvd) { return join(l$prime, v, d, r$prime); } @@ -573,33 +558,30 @@ function Make(funarg) { }; var partition = function (p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var match = partition(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var d = param[2]; + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pvd = Caml_curry.app2(p, v, d); - var match$1 = partition(p, param[4]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition(p, param[3]); + var rf = match$1[1]; + var rt = match$1[0]; if (pvd) { - return [ - /* tuple */0, + return /* tuple */[ join(lt, v, d, rt), concat(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat(lt, rt), join(lf, v, d, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -610,14 +592,15 @@ function Make(funarg) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -634,18 +617,18 @@ function Make(funarg) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_curry.app2(funarg[1], e1[1], e2[1]); + var c = Caml_curry.app2(funarg[0], e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -671,12 +654,12 @@ function Make(funarg) { var e1 = _e1; if (e1) { if (e2) { - if (Caml_curry.app2(funarg[1], e1[1], e2[1])) { + if (Caml_curry.app2(funarg[0], e1[0], e2[0])) { return /* false */0; } - else if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + else if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -698,7 +681,7 @@ function Make(funarg) { }; var cardinal = function (param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[4]); + return cardinal(param[0]) + 1 + cardinal(param[3]); } else { return 0; @@ -709,15 +692,13 @@ function Make(funarg) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - [ - /* tuple */0, - param[2], - param[3] + _param = param[0]; + _accu = /* :: */[ + /* tuple */[ + param[1], + param[2] ], - bindings_aux(accu, param[4]) + bindings_aux(accu, param[3]) ]; continue ; @@ -731,7 +712,6 @@ function Make(funarg) { return bindings_aux(/* [] */0, s); }; return [ - 0, /* Empty */0, is_empty, mem, diff --git a/jscomp/stdlib/marshal.js b/jscomp/stdlib/marshal.js index fe91365fc9..15689a034e 100644 --- a/jscomp/stdlib/marshal.js +++ b/jscomp/stdlib/marshal.js @@ -8,7 +8,6 @@ var Caml_string = require("../runtime/caml_string"); function to_buffer(buff, ofs, len, v, flags) { if (ofs < 0 || len < 0 || ofs > buff.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Marshal.to_buffer: substring out of bounds" ]; @@ -23,7 +22,6 @@ var header_size = 20; function data_size(buff, ofs) { if (ofs < 0 || ofs > buff.length - header_size) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Marshal.data_size" ]; @@ -40,7 +38,6 @@ function total_size(buff, ofs) { function from_bytes(buff, ofs) { if (ofs < 0 || ofs > buff.length - header_size) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Marshal.from_bytes" ]; @@ -49,7 +46,6 @@ function from_bytes(buff, ofs) { var len = Caml_primitive.caml_marshal_data_size(buff, ofs); if (ofs > buff.length - (header_size + len)) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Marshal.from_bytes" ]; diff --git a/jscomp/stdlib/nativeint.js b/jscomp/stdlib/nativeint.js index 113eb9a127..398b2b2324 100644 --- a/jscomp/stdlib/nativeint.js +++ b/jscomp/stdlib/nativeint.js @@ -1,9 +1,9 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_format = require("../runtime/caml_format"); -var Sys = require("./sys"); -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_obj = require("../runtime/caml_obj"); +var Caml_format = require("../runtime/caml_format"); +var Sys = require("./sys"); function succ(n) { return n + 1; @@ -37,7 +37,7 @@ function to_string(n) { } function compare(x, y) { - return Caml_primitive.caml_nativeint_compare(x, y); + return Caml_obj.caml_nativeint_compare(x, y); } var zero = 0; diff --git a/jscomp/stdlib/obj.js b/jscomp/stdlib/obj.js index 1c480d540d..12f4acbbdf 100644 --- a/jscomp/stdlib/obj.js +++ b/jscomp/stdlib/obj.js @@ -1,8 +1,8 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_obj = require("../runtime/caml_obj"); var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var Marshal = require("./marshal"); var Caml_primitive = require("../runtime/caml_primitive"); @@ -20,8 +20,7 @@ function marshal(obj) { } function unmarshal(str, pos) { - return [ - /* tuple */0, + return /* tuple */[ Marshal.from_bytes(str, pos), pos + Marshal.total_size(str, pos) ]; @@ -34,15 +33,15 @@ var string_tag = 252; var custom_tag = 255; function extension_slot(x) { - var slot = Caml_obj_runtime.caml_obj_is_block(x) && Caml_obj_runtime.caml_obj_tag(x) !== object_tag && x.length >= 1 ? x[0] : x; + var slot = Caml_obj.caml_obj_is_block(x) && (x.tag | 0) !== object_tag && x.length >= 1 ? x[0] : x; var name; - if (Caml_obj_runtime.caml_obj_is_block(slot) && Caml_obj_runtime.caml_obj_tag(slot) === object_tag) { + if (Caml_obj.caml_obj_is_block(slot) && (slot.tag | 0) === object_tag) { name = slot[0]; } else { throw Caml_builtin_exceptions.Not_found; } - if (Caml_obj_runtime.caml_obj_tag(name) === string_tag) { + if ((name.tag | 0) === string_tag) { return slot; } else { @@ -58,7 +57,6 @@ function extension_name(x) { catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Obj.extension_name" ]; @@ -77,7 +75,6 @@ function extension_id(x) { catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Obj.extension_id" ]; @@ -95,7 +92,6 @@ function extension_slot$1(x) { catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Obj.extension_slot" ]; diff --git a/jscomp/stdlib/parsing.js b/jscomp/stdlib/parsing.js index 5e49fcf4e6..b4642bf28d 100644 --- a/jscomp/stdlib/parsing.js +++ b/jscomp/stdlib/parsing.js @@ -2,28 +2,28 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); +var Caml_obj = require("../runtime/caml_obj"); +var Caml_parser = require("../runtime/caml_parser"); var Lexing = require("./lexing"); -var Caml_lexer = require("../runtime/caml_lexer"); -var Caml_primitive = require("../runtime/caml_primitive"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("./array"); var Caml_curry = require("../runtime/caml_curry"); -var YYexit = [ - 248, - "Parsing.YYexit", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; - -var Parse_error = [ - 248, - "Parsing.Parse_error", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; - -var env = [ - /* record */0, +var YYexit = { + 0: "Parsing.YYexit", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; + +var Parse_error = { + 0: "Parsing.Parse_error", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; + +var env = /* record */[ Caml_array.caml_make_vect(100, 0), Caml_array.caml_make_vect(100, /* () */0), Caml_array.caml_make_vect(100, Lexing.dummy_pos), @@ -43,60 +43,57 @@ var env = [ ]; function grow_stacks() { - var oldsize = env[5]; + var oldsize = env[4]; var newsize = oldsize * 2; var new_s = Caml_array.caml_make_vect(newsize, 0); var new_v = Caml_array.caml_make_vect(newsize, /* () */0); var new_start = Caml_array.caml_make_vect(newsize, Lexing.dummy_pos); var new_end = Caml_array.caml_make_vect(newsize, Lexing.dummy_pos); - $$Array.blit(env[1], 0, new_s, 0, oldsize); - env[1] = new_s; - $$Array.blit(env[2], 0, new_v, 0, oldsize); - env[2] = new_v; - $$Array.blit(env[3], 0, new_start, 0, oldsize); - env[3] = new_start; - $$Array.blit(env[4], 0, new_end, 0, oldsize); - env[4] = new_end; - env[5] = newsize; + $$Array.blit(env[0], 0, new_s, 0, oldsize); + env[0] = new_s; + $$Array.blit(env[1], 0, new_v, 0, oldsize); + env[1] = new_v; + $$Array.blit(env[2], 0, new_start, 0, oldsize); + env[2] = new_start; + $$Array.blit(env[3], 0, new_end, 0, oldsize); + env[3] = new_end; + env[4] = newsize; return /* () */0; } function clear_parser() { - $$Array.fill(env[2], 0, env[5], /* () */0); - env[8] = /* () */0; + $$Array.fill(env[1], 0, env[4], /* () */0); + env[7] = /* () */0; return /* () */0; } -var current_lookahead_fun = [ - 0, - function () { +var current_lookahead_fun = [function () { return /* false */0; - } -]; + }]; function yyparse(tables, start, lexer, lexbuf) { - var init_asp = env[11]; - var init_sp = env[14]; - var init_stackbase = env[6]; - var init_state = env[15]; - var init_curr_char = env[7]; - var init_lval = env[8]; - var init_errflag = env[16]; - env[6] = env[14] + 1; - env[7] = start; - env[10] = lexbuf[12]; + var init_asp = env[10]; + var init_sp = env[13]; + var init_stackbase = env[5]; + var init_state = env[14]; + var init_curr_char = env[6]; + var init_lval = env[7]; + var init_errflag = env[15]; + env[5] = env[13] + 1; + env[6] = start; + env[9] = lexbuf[11]; try { var _cmd = /* Start */0; var _arg = /* () */0; while(true) { var arg = _arg; var cmd = _cmd; - var match = Caml_lexer.caml_parse_engine(tables, env, cmd, arg); + var match = Caml_parser.caml_parse_engine(tables, env, cmd, arg); switch (match) { case 0 : var t = Caml_curry.app1(lexer, lexbuf); + env[8] = lexbuf[10]; env[9] = lexbuf[11]; - env[10] = lexbuf[12]; _arg = t; _cmd = /* Token_read */1; continue ; @@ -115,16 +112,14 @@ function yyparse(tables, start, lexer, lexbuf) { case 4 : var match$1; try { - match$1 = [ - /* tuple */0, + match$1 = /* tuple */[ /* Semantic_action_computed */4, - Caml_curry.app1(tables[1][env[13]], env) + Caml_curry.app1(tables[0][env[12]], env) ]; } catch (exn){ if (exn === Parse_error) { - match$1 = [ - /* tuple */0, + match$1 = /* tuple */[ /* Error_detected */5, /* () */0 ]; @@ -133,11 +128,11 @@ function yyparse(tables, start, lexer, lexbuf) { throw exn; } } - _arg = match$1[2]; - _cmd = match$1[1]; + _arg = match$1[1]; + _cmd = match$1[0]; continue ; case 5 : - Caml_curry.app1(tables[14], "syntax error"); + Caml_curry.app1(tables[13], "syntax error"); _arg = /* () */0; _cmd = /* Error_detected */5; continue ; @@ -146,24 +141,24 @@ function yyparse(tables, start, lexer, lexbuf) { }; } catch (exn$1){ - var curr_char = env[7]; - env[11] = init_asp; - env[14] = init_sp; - env[6] = init_stackbase; - env[15] = init_state; - env[7] = init_curr_char; - env[8] = init_lval; - env[16] = init_errflag; - if (exn$1[1] === YYexit) { - return exn$1[2]; + var curr_char = env[6]; + env[10] = init_asp; + env[13] = init_sp; + env[5] = init_stackbase; + env[14] = init_state; + env[6] = init_curr_char; + env[7] = init_lval; + env[15] = init_errflag; + if (exn$1[0] === YYexit) { + return exn$1[1]; } else { - current_lookahead_fun[1] = function (tok) { - if (Caml_obj_runtime.caml_obj_is_block(tok)) { - return +(tables[3][Caml_obj_runtime.caml_obj_tag(tok)] === curr_char); + current_lookahead_fun[0] = function (tok) { + if (Caml_obj.caml_obj_is_block(tok)) { + return +(tables[2][tok.tag | 0] === curr_char); } else { - return +(tables[2][tok] === curr_char); + return +(tables[1][tok] === curr_char); } }; throw exn$1; @@ -172,20 +167,20 @@ function yyparse(tables, start, lexer, lexbuf) { } function peek_val(env, n) { - return env[2][env[11] - n]; + return env[1][env[10] - n]; } function symbol_start_pos() { - var _i = env[12]; + var _i = env[11]; while(true) { var i = _i; if (i <= 0) { - return env[4][env[11]]; + return env[3][env[10]]; } else { - var st = env[3][env[11] - i + 1]; - var en = env[4][env[11] - i + 1]; - if (Caml_primitive.caml_notequal(st, en)) { + var st = env[2][env[10] - i + 1]; + var en = env[3][env[10] - i + 1]; + if (Caml_obj.caml_notequal(st, en)) { return st; } else { @@ -198,35 +193,35 @@ function symbol_start_pos() { } function symbol_end_pos() { - return env[4][env[11]]; + return env[3][env[10]]; } function rhs_start_pos(n) { - return env[3][env[11] - (env[12] - n)]; + return env[2][env[10] - (env[11] - n)]; } function rhs_end_pos(n) { - return env[4][env[11] - (env[12] - n)]; + return env[3][env[10] - (env[11] - n)]; } function symbol_start() { - return symbol_start_pos(/* () */0)[4]; + return symbol_start_pos(/* () */0)[3]; } function symbol_end() { - return symbol_end_pos(/* () */0)[4]; + return symbol_end_pos(/* () */0)[3]; } function rhs_start(n) { - return rhs_start_pos(n)[4]; + return rhs_start_pos(n)[3]; } function rhs_end(n) { - return rhs_end_pos(n)[4]; + return rhs_end_pos(n)[3]; } function is_current_lookahead(tok) { - return Caml_curry.app1(current_lookahead_fun[1], tok); + return Caml_curry.app1(current_lookahead_fun[0], tok); } function parse_error() { @@ -234,7 +229,7 @@ function parse_error() { } function set_trace(prim) { - return Caml_lexer.caml_set_parser_trace(prim); + return Caml_parser.caml_set_parser_trace(prim); } exports.symbol_start = symbol_start; diff --git a/jscomp/stdlib/pervasives.js b/jscomp/stdlib/pervasives.js index 8e188606a8..9b7dced1aa 100644 --- a/jscomp/stdlib/pervasives.js +++ b/jscomp/stdlib/pervasives.js @@ -2,6 +2,7 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Caml_io = require("../runtime/caml_io"); var Caml_format = require("../runtime/caml_format"); var Caml_primitive = require("../runtime/caml_primitive"); @@ -11,7 +12,6 @@ var Caml_string = require("../runtime/caml_string"); function failwith(s) { throw [ - 0, Caml_builtin_exceptions.Failure, s ]; @@ -19,20 +19,20 @@ function failwith(s) { function invalid_arg(s) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, s ]; } -var Exit = [ - 248, - "Pervasives.Exit", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Exit = { + 0: "Pervasives.Exit", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function min(x, y) { - if (Caml_primitive.caml_lessequal(x, y)) { + if (Caml_obj.caml_lessequal(x, y)) { return x; } else { @@ -41,7 +41,7 @@ function min(x, y) { } function max(x, y) { - if (Caml_primitive.caml_greaterequal(x, y)) { + if (Caml_obj.caml_greaterequal(x, y)) { return x; } else { @@ -85,7 +85,6 @@ function $caret(a, b) { function char_of_int(n) { if (n < 0 || n > 255) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "char_of_int" ]; @@ -112,7 +111,6 @@ function bool_of_string(param) { return /* true */1; default: throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "bool_of_string" ]; @@ -161,10 +159,9 @@ function string_of_float(f) { function $at(l1, l2) { if (l1) { - return [ - /* :: */0, - l1[1], - $at(l1[2], l2) + return /* :: */[ + l1[0], + $at(l1[1], l2) ]; } else { @@ -183,17 +180,13 @@ function open_out_gen(mode, perm, name) { } function open_out(name) { - return open_out_gen([ - /* :: */0, + return open_out_gen(/* :: */[ /* Open_wronly */1, - [ - /* :: */0, + /* :: */[ /* Open_creat */3, - [ - /* :: */0, + /* :: */[ /* Open_trunc */4, - [ - /* :: */0, + /* :: */[ /* Open_text */7, /* [] */0 ] @@ -203,17 +196,13 @@ function open_out(name) { } function open_out_bin(name) { - return open_out_gen([ - /* :: */0, + return open_out_gen(/* :: */[ /* Open_wronly */1, - [ - /* :: */0, + /* :: */[ /* Open_creat */3, - [ - /* :: */0, + /* :: */[ /* Open_trunc */4, - [ - /* :: */0, + /* :: */[ /* Open_binary */6, /* [] */0 ] @@ -228,12 +217,12 @@ function flush_all() { var param = _param; if (param) { try { - Caml_io.caml_ml_flush(param[1]); + Caml_io.caml_ml_flush(param[0]); } catch (exn){ } - _param = param[2]; + _param = param[1]; continue ; } @@ -254,7 +243,6 @@ function output_string(oc, s) { function output(oc, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "output" ]; @@ -267,7 +255,6 @@ function output(oc, s, ofs, len) { function output_substring(oc, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "output_substring" ]; @@ -306,11 +293,9 @@ function open_in_gen(mode, perm, name) { } function open_in(name) { - return open_in_gen([ - /* :: */0, + return open_in_gen(/* :: */[ /* Open_rdonly */0, - [ - /* :: */0, + /* :: */[ /* Open_text */7, /* [] */0 ] @@ -318,11 +303,9 @@ function open_in(name) { } function open_in_bin(name) { - return open_in_gen([ - /* :: */0, + return open_in_gen(/* :: */[ /* Open_rdonly */0, - [ - /* :: */0, + /* :: */[ /* Open_binary */6, /* [] */0 ] @@ -332,7 +315,6 @@ function open_in_bin(name) { function input(ic, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "input" ]; @@ -367,7 +349,6 @@ function unsafe_really_input(ic, s, _ofs, _len) { function really_input(ic, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "really_input" ]; @@ -389,10 +370,10 @@ function input_line(chan) { var param = _param; var pos = _pos; if (param) { - var hd = param[1]; + var hd = param[0]; var len = hd.length; Caml_string.caml_blit_bytes(hd, 0, buf, pos - len, len); - _param = param[2]; + _param = param[1]; _pos = pos - len; continue ; @@ -414,8 +395,7 @@ function input_line(chan) { Caml_io.caml_ml_input_char(chan); if (accu) { var len$1 = len + n - 1; - return build_result(Caml_string.caml_create_string(len$1), len$1, [ - /* :: */0, + return build_result(Caml_string.caml_create_string(len$1), len$1, /* :: */[ res, accu ]); @@ -428,8 +408,7 @@ function input_line(chan) { var beg = Caml_string.caml_create_string(-n); Caml_primitive.caml_ml_input(chan, beg, 0, -n); _len = len - n; - _accu = [ - /* :: */0, + _accu = /* :: */[ beg, accu ]; @@ -525,25 +504,23 @@ function read_float() { } function string_of_format(param) { - return param[2]; + return param[1]; } function $caret$caret(param, param$1) { - return [ - /* Format */0, - CamlinternalFormatBasics.concat_fmt(param[1], param$1[1]), - $caret(param[2], $caret("%,", param$1[2])) - ]; + return /* Format */{ + 0: CamlinternalFormatBasics.concat_fmt(param[0], param$1[0]), + 1: $caret(param[1], $caret("%,", param$1[1])), + length: 2, + tag: 0 + }; } -var exit_function = [ - 0, - flush_all -]; +var exit_function = [flush_all]; function at_exit(f) { - var g = exit_function[1]; - exit_function[1] = function () { + var g = exit_function[0]; + exit_function[0] = function () { Caml_curry.app1(f, /* () */0); return Caml_curry.app1(g, /* () */0); }; @@ -551,7 +528,7 @@ function at_exit(f) { } function do_at_exit() { - return Caml_curry.app1(exit_function[1], /* () */0); + return Caml_curry.app1(exit_function[0], /* () */0); } function exit(retcode) { @@ -627,38 +604,37 @@ function set_binary_mode_in(prim, prim$1) { return Caml_primitive.caml_ml_set_binary_mode(prim, prim$1); } -function LargeFile_001(prim, prim$1) { +function LargeFile_000(prim, prim$1) { return Caml_primitive.caml_ml_seek_out_64(prim, prim$1); } -function LargeFile_002(prim) { +function LargeFile_001(prim) { return Caml_primitive.caml_ml_pos_out_64(prim); } -function LargeFile_003(prim) { +function LargeFile_002(prim) { return Caml_primitive.caml_ml_channel_size_64(prim); } -function LargeFile_004(prim, prim$1) { +function LargeFile_003(prim, prim$1) { return Caml_primitive.caml_ml_seek_in_64(prim, prim$1); } -function LargeFile_005(prim) { +function LargeFile_004(prim) { return Caml_primitive.caml_ml_pos_in_64(prim); } -function LargeFile_006(prim) { +function LargeFile_005(prim) { return Caml_primitive.caml_ml_channel_size_64(prim); } var LargeFile = [ - 0, + LargeFile_000, LargeFile_001, LargeFile_002, LargeFile_003, LargeFile_004, - LargeFile_005, - LargeFile_006 + LargeFile_005 ]; exports.invalid_arg = invalid_arg; diff --git a/jscomp/stdlib/printexc.js b/jscomp/stdlib/printexc.js index f55c4dff39..e68d76b041 100644 --- a/jscomp/stdlib/printexc.js +++ b/jscomp/stdlib/printexc.js @@ -1,9 +1,9 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_obj = require("../runtime/caml_obj"); var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); var Caml_io = require("../runtime/caml_io"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var Obj = require("./obj"); var Pervasives = require("./pervasives"); var Printf = require("./printf"); @@ -12,78 +12,88 @@ var $$Array = require("./array"); var Buffer = require("./buffer"); var Caml_curry = require("../runtime/caml_curry"); -var printers = [ - 0, - /* [] */0 -]; - -var locfmt = [ - /* Format */0, - [ - /* String_literal */11, - 'File "', - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - '", line ', - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", characters ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "-" */45, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ": ", - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ], - 'File "%s", line %d, characters %d-%d: %s' -]; +var printers = [/* [] */0]; + +var locfmt = /* Format */{ + 0: /* String_literal */{ + 0: 'File "', + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: '", line ', + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", characters ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "-" */45, + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ": ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: 'File "%s", line %d, characters %d-%d: %s', + length: 2, + tag: 0 +}; function field(x, i) { var f = x[i]; - if (Caml_obj_runtime.caml_obj_is_block(f)) { - if (Caml_obj_runtime.caml_obj_tag(f) === Obj.string_tag) { - return Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ], - "%S" - ]), f); + if (Caml_obj.caml_obj_is_block(f)) { + if ((f.tag | 0) === Obj.string_tag) { + return Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 3 + }, + 1: "%S", + length: 2, + tag: 0 + }), f); } - else if (Caml_obj_runtime.caml_obj_tag(f) === Obj.double_tag) { + else if ((f.tag | 0) === Obj.double_tag) { return Pervasives.string_of_float(f); } else { @@ -91,17 +101,19 @@ function field(x, i) { } } else { - return Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 - ], - "%d" - ]), f); + return Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 4 + }, + 1: "%d", + length: 2, + tag: 0 + }), f); } } @@ -110,50 +122,59 @@ function other_fields(x, i) { return ""; } else { - return Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - ", ", - [ - /* String */2, - /* No_padding */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ], - ", %s%s" - ]), field(x, i), other_fields(x, i + 1)); + return Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: ", ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: ", %s%s", + length: 2, + tag: 0 + }), field(x, i), other_fields(x, i + 1)); } } function fields(x) { var n = x.length; if (n > 2 || n < 0) { - return Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* Char_literal */12, - /* "(" */40, - [ - /* String */2, - /* No_padding */0, - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* ")" */41, - /* End_of_format */0 - ] - ] - ] - ], - "(%s%s)" - ]), field(x, 1), other_fields(x, 2)); + return Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* Char_literal */{ + 0: /* "(" */40, + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* ")" */41, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 12 + }, + 1: "(%s%s)", + length: 2, + tag: 0 + }), field(x, 1), other_fields(x, 2)); } else { switch (n) { @@ -161,45 +182,49 @@ function fields(x) { case 1 : return ""; case 2 : - return Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* Char_literal */12, - /* "(" */40, - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* ")" */41, - /* End_of_format */0 - ] - ] - ], - "(%s)" - ]), field(x, 1)); + return Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* Char_literal */{ + 0: /* "(" */40, + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* ")" */41, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 12 + }, + 1: "(%s)", + length: 2, + tag: 0 + }), field(x, 1)); } } } function to_string(x) { - var _param = printers[1]; + var _param = printers[0]; while(true) { var param = _param; if (param) { var match; try { - match = Caml_curry.app1(param[1], x); + match = Caml_curry.app1(param[0], x); } catch (exn){ match = /* None */0; } if (match) { - return match[1]; + return match[0]; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -210,22 +235,22 @@ function to_string(x) { else if (x === Caml_builtin_exceptions.Stack_overflow) { return "Stack overflow"; } - else if (x[1] === Caml_builtin_exceptions.Match_failure) { - var match$1 = x[2]; - var $$char = match$1[3]; - return Caml_curry.app5(Printf.sprintf(locfmt), match$1[1], match$1[2], $$char, $$char + 5, "Pattern matching failed"); + else if (x[0] === Caml_builtin_exceptions.Match_failure) { + var match$1 = x[1]; + var $$char = match$1[2]; + return Caml_curry.app5(Printf.sprintf(locfmt), match$1[0], match$1[1], $$char, $$char + 5, "Pattern matching failed"); } - else if (x[1] === Caml_builtin_exceptions.Assert_failure) { - var match$2 = x[2]; - var $$char$1 = match$2[3]; - return Caml_curry.app5(Printf.sprintf(locfmt), match$2[1], match$2[2], $$char$1, $$char$1 + 6, "Assertion failed"); + else if (x[0] === Caml_builtin_exceptions.Assert_failure) { + var match$2 = x[1]; + var $$char$1 = match$2[2]; + return Caml_curry.app5(Printf.sprintf(locfmt), match$2[0], match$2[1], $$char$1, $$char$1 + 6, "Assertion failed"); } - else if (x[1] === Caml_builtin_exceptions.Undefined_recursive_module) { - var match$3 = x[2]; - var $$char$2 = match$3[3]; - return Caml_curry.app5(Printf.sprintf(locfmt), match$3[1], match$3[2], $$char$2, $$char$2 + 6, "Undefined recursive module"); + else if (x[0] === Caml_builtin_exceptions.Undefined_recursive_module) { + var match$3 = x[1]; + var $$char$2 = match$3[2]; + return Caml_curry.app5(Printf.sprintf(locfmt), match$3[0], match$3[1], $$char$2, $$char$2 + 6, "Undefined recursive module"); } - else if (Caml_obj_runtime.caml_obj_tag(x) !== 0) { + else if ((x.tag | 0) !== 0) { return x[0]; } else { @@ -240,23 +265,27 @@ function print(fct, arg) { return Caml_curry.app1(fct, arg); } catch (x){ - Caml_curry.app1(Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "Uncaught exception: ", - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "Uncaught exception: %s\n" - ]), to_string(x)); + Caml_curry.app1(Printf.eprintf(/* Format */{ + 0: /* String_literal */{ + 0: "Uncaught exception: ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "Uncaught exception: %s\n", + length: 2, + tag: 0 + }), to_string(x)); Caml_io.caml_ml_flush(Pervasives.stderr); throw x; } @@ -268,38 +297,39 @@ function $$catch(fct, arg) { } catch (x){ Caml_io.caml_ml_flush(Pervasives.stdout); - Caml_curry.app1(Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "Uncaught exception: ", - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "Uncaught exception: %s\n" - ]), to_string(x)); + Caml_curry.app1(Printf.eprintf(/* Format */{ + 0: /* String_literal */{ + 0: "Uncaught exception: ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "Uncaught exception: %s\n", + length: 2, + tag: 0 + }), to_string(x)); return Pervasives.exit(2); } } function convert_raw_backtrace(rbckt) { try { - return [ - /* Some */0, - $$Array.map(function (prim) { + return /* Some */[$$Array.map(function (prim) { return Caml_primitive.caml_convert_raw_backtrace_slot(prim); - }, rbckt) - ]; + }, rbckt)]; } catch (exn){ - if (exn[1] === Caml_builtin_exceptions.Failure) { + if (exn[0] === Caml_builtin_exceptions.Failure) { return /* None */0; } else { @@ -325,80 +355,87 @@ function format_backtrace_slot(pos, slot) { return "Raised by primitive operation at"; } }; - if (slot[0]) { - if (slot[1] !== 0) { + if (slot.tag) { + if (slot[0] !== 0) { return /* None */0; } else { - return [ - /* Some */0, - Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - " unknown location", - /* End_of_format */0 - ] - ], - "%s unknown location" - ]), info(/* false */0)) - ]; + return /* Some */[Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " unknown location", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + 1: "%s unknown location", + length: 2, + tag: 0 + }), info(/* false */0))]; } } else { - return [ - /* Some */0, - Caml_curry.app5(Printf.sprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - ' file "', - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - '", line ', - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ", characters ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "-" */45, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ] - ] - ], - '%s file "%s", line %d, characters %d-%d' - ]), info(slot[1]), slot[2], slot[3], slot[4], slot[5]) - ]; + return /* Some */[Caml_curry.app5(Printf.sprintf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: ' file "', + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: '", line ', + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ", characters ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "-" */45, + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 4 + }, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + 1: '%s file "%s", line %d, characters %d-%d', + length: 2, + tag: 0 + }), info(slot[0]), slot[1], slot[2], slot[3], slot[4])]; } } @@ -406,38 +443,43 @@ function print_raw_backtrace(outchan, raw_backtrace) { var outchan$1 = outchan; var backtrace = convert_raw_backtrace(raw_backtrace); if (backtrace) { - var a = backtrace[1]; + var a = backtrace[0]; for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ var match = format_backtrace_slot(i, a[i]); if (match) { - Caml_curry.app1(Printf.fprintf(outchan$1, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ], - "%s\n" - ]), match[1]); + Caml_curry.app1(Printf.fprintf(outchan$1, /* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + 1: "%s\n", + length: 2, + tag: 0 + }), match[0]); } } return /* () */0; } else { - return Printf.fprintf(outchan$1, [ - /* Format */0, - [ - /* String_literal */11, - "(Program not linked with -g, cannot print stack backtrace)\n", - /* End_of_format */0 - ], - "(Program not linked with -g, cannot print stack backtrace)\n" - ]); + return Printf.fprintf(outchan$1, /* Format */{ + 0: /* String_literal */{ + 0: "(Program not linked with -g, cannot print stack backtrace)\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + 1: "(Program not linked with -g, cannot print stack backtrace)\n", + length: 2, + tag: 0 + }); } } @@ -447,24 +489,27 @@ function print_backtrace(outchan) { function backtrace_to_string(backtrace) { if (backtrace) { - var a = backtrace[1]; + var a = backtrace[0]; var b = Buffer.create(1024); for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ var match = format_backtrace_slot(i, a[i]); if (match) { - Caml_curry.app1(Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ], - "%s\n" - ]), match[1]); + Caml_curry.app1(Printf.bprintf(b, /* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + 1: "%s\n", + length: 2, + tag: 0 + }), match[0]); } } @@ -480,33 +525,29 @@ function raw_backtrace_to_string(raw_backtrace) { } function backtrace_slot_is_raise(param) { - return param[1]; + return param[0]; } function backtrace_slot_location(param) { - if (param[0]) { + if (param.tag) { return /* None */0; } else { - return [ - /* Some */0, - [ - /* record */0, + return /* Some */[/* record */[ + param[1], param[2], param[3], - param[4], - param[5] - ] - ]; + param[4] + ]]; } } function backtrace_slots(raw_backtrace) { var match = convert_raw_backtrace(raw_backtrace); if (match) { - var backtrace = match[1]; + var backtrace = match[0]; var usable_slot = function (param) { - if (param[0]) { + if (param.tag) { return /* false */0; } else { @@ -532,10 +573,7 @@ function backtrace_slots(raw_backtrace) { }; }; if (exists_usable(backtrace.length - 1)) { - return [ - /* Some */0, - backtrace - ]; + return /* Some */[backtrace]; } else { return /* None */0; @@ -559,16 +597,15 @@ function get_backtrace() { } function register_printer(fn) { - printers[1] = [ - /* :: */0, + printers[0] = /* :: */[ fn, - printers[1] + printers[0] ]; return /* () */0; } function exn_slot(x) { - if (Caml_obj_runtime.caml_obj_tag(x)) { + if (x.tag) { return x; } else { @@ -586,16 +623,10 @@ function exn_slot_name(x) { return slot[0]; } -var uncaught_exception_handler = [ - 0, - /* None */0 -]; +var uncaught_exception_handler = [/* None */0]; function set_uncaught_exception_handler(fn) { - uncaught_exception_handler[1] = [ - /* Some */0, - fn - ]; + uncaught_exception_handler[0] = /* Some */[fn]; return /* () */0; } @@ -616,7 +647,6 @@ function get_callstack() { } var Slot = [ - 0, backtrace_slot_is_raise, backtrace_slot_location, format_backtrace_slot diff --git a/jscomp/stdlib/printf.js b/jscomp/stdlib/printf.js index 700027b52c..d70bbfce4b 100644 --- a/jscomp/stdlib/printf.js +++ b/jscomp/stdlib/printf.js @@ -10,20 +10,20 @@ function kfprintf(k, o, param) { return CamlinternalFormat.make_printf(function (o, acc) { CamlinternalFormat.output_acc(o, acc); return Caml_curry.app1(k, o); - }, o, /* End_of_acc */0, param[1]); + }, o, /* End_of_acc */0, param[0]); } function kbprintf(k, b, param) { return CamlinternalFormat.make_printf(function (b, acc) { CamlinternalFormat.bufput_acc(b, acc); return Caml_curry.app1(k, b); - }, b, /* End_of_acc */0, param[1]); + }, b, /* End_of_acc */0, param[0]); } function ikfprintf(k, oc, param) { return CamlinternalFormat.make_printf(function (oc, _) { return Caml_curry.app1(k, oc); - }, oc, /* End_of_acc */0, param[1]); + }, oc, /* End_of_acc */0, param[0]); } function fprintf(oc, fmt) { @@ -58,7 +58,7 @@ function ksprintf(k, param) { CamlinternalFormat.strput_acc(buf, acc); return Caml_curry.app1(k, Buffer.contents(buf)); }; - return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[1]); + return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[0]); } function sprintf(fmt) { diff --git a/jscomp/stdlib/queue.js b/jscomp/stdlib/queue.js index e212f6d7cd..b7512a70dd 100644 --- a/jscomp/stdlib/queue.js +++ b/jscomp/stdlib/queue.js @@ -2,59 +2,59 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_obj = require("../runtime/caml_obj"); var Caml_curry = require("../runtime/caml_curry"); -var Empty = [ - 248, - "Queue.Empty", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Empty = { + 0: "Queue.Empty", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function create() { - return [ - /* record */0, + return /* record */[ 0, /* None */0 ]; } function clear(q) { - q[1] = 0; - q[2] = /* None */0; + q[0] = 0; + q[1] = /* None */0; return /* () */0; } function add(x, q) { - if (q[1]) { - var tail = q[2]; - var head = tail[2]; - var cell = [ - /* record */0, + if (q[0]) { + var tail = q[1]; + var head = tail[1]; + var cell = /* record */[ x, head ]; - ++ q[1]; - tail[2] = cell; - q[2] = cell; + ++ q[0]; + tail[1] = cell; + q[1] = cell; return /* () */0; } else { - var cell$1 = []; - Caml_primitive.caml_update_dummy(cell$1, [ - /* record */0, + var cell$1 = { + + }; + Caml_obj.caml_update_dummy(cell$1, /* record */[ x, cell$1 ]); - q[1] = 1; - q[2] = cell$1; + q[0] = 1; + q[1] = cell$1; return /* () */0; } } function peek(q) { - if (q[1]) { - return q[2][2][1]; + if (q[0]) { + return q[1][1][0]; } else { throw Empty; @@ -62,28 +62,29 @@ function peek(q) { } function take(q) { - if (!q[1]) { + if (!q[0]) { throw Empty; } - -- q[1]; - var tail = q[2]; - var head = tail[2]; + -- q[0]; + var tail = q[1]; + var head = tail[1]; if (head === tail) { - q[2] = /* None */0; + q[1] = /* None */0; } else { - tail[2] = head[2]; + tail[1] = head[1]; } - return head[1]; + return head[0]; } function copy(q) { - if (q[1]) { - var tail = q[2]; - var tail$prime = []; - Caml_primitive.caml_update_dummy(tail$prime, [ - /* record */0, - tail[1], + if (q[0]) { + var tail = q[1]; + var tail$prime = { + + }; + Caml_obj.caml_update_dummy(tail$prime, /* record */[ + tail[0], tail$prime ]); var copy$1 = function (_prev, _cell) { @@ -91,13 +92,12 @@ function copy(q) { var cell = _cell; var prev = _prev; if (cell !== tail) { - var res = [ - /* record */0, - cell[1], + var res = /* record */[ + cell[0], tail$prime ]; - prev[2] = res; - _cell = cell[2]; + prev[1] = res; + _cell = cell[1]; _prev = res; continue ; @@ -107,16 +107,14 @@ function copy(q) { } }; }; - copy$1(tail$prime, tail[2]); - return [ - /* record */0, - q[1], + copy$1(tail$prime, tail[1]); + return /* record */[ + q[0], tail$prime ]; } else { - return [ - /* record */0, + return /* record */[ 0, /* None */0 ]; @@ -124,22 +122,22 @@ function copy(q) { } function is_empty(q) { - return +(q[1] === 0); + return +(q[0] === 0); } function length(q) { - return q[1]; + return q[0]; } function iter(f, q) { - if (q[1] > 0) { - var tail = q[2]; - var _cell = tail[2]; + if (q[0] > 0) { + var tail = q[1]; + var _cell = tail[1]; while(true) { var cell = _cell; - Caml_curry.app1(f, cell[1]); + Caml_curry.app1(f, cell[0]); if (cell !== tail) { - _cell = cell[2]; + _cell = cell[1]; continue ; } @@ -154,19 +152,19 @@ function iter(f, q) { } function fold(f, accu, q) { - if (q[1]) { - var tail = q[2]; + if (q[0]) { + var tail = q[1]; var _accu = accu; - var _cell = tail[2]; + var _cell = tail[1]; while(true) { var cell = _cell; var accu$1 = _accu; - var accu$2 = Caml_curry.app2(f, accu$1, cell[1]); + var accu$2 = Caml_curry.app2(f, accu$1, cell[0]); if (cell === tail) { return accu$2; } else { - _cell = cell[2]; + _cell = cell[1]; _accu = accu$2; continue ; @@ -179,19 +177,19 @@ function fold(f, accu, q) { } function transfer(q1, q2) { - var length1 = q1[1]; + var length1 = q1[0]; if (length1 > 0) { - var tail1 = q1[2]; + var tail1 = q1[1]; clear(q1); - if (q2[1] > 0) { - var tail2 = q2[2]; - var head1 = tail1[2]; - var head2 = tail2[2]; - tail1[2] = head2; - tail2[2] = head1; + if (q2[0] > 0) { + var tail2 = q2[1]; + var head1 = tail1[1]; + var head2 = tail2[1]; + tail1[1] = head2; + tail2[1] = head1; } - q2[1] += length1; - q2[2] = tail1; + q2[0] += length1; + q2[1] = tail1; return /* () */0; } else { diff --git a/jscomp/stdlib/random.js b/jscomp/stdlib/random.js index 01a91827c7..cd09417dca 100644 --- a/jscomp/stdlib/random.js +++ b/jscomp/stdlib/random.js @@ -13,16 +13,15 @@ var $$Array = require("./array"); var Caml_curry = require("../runtime/caml_curry"); function new_state() { - return [ - /* record */0, + return /* record */[ Caml_array.caml_make_vect(55, 0), 0 ]; } function assign(st1, st2) { - $$Array.blit(st2[1], 0, st1[1], 0, 55); - st1[2] = st2[2]; + $$Array.blit(st2[0], 0, st1[0], 0, 55); + st1[1] = st2[1]; return /* () */0; } @@ -33,19 +32,19 @@ function full_init(s, seed) { var extract = function (d) { return d.charCodeAt(0) + (d.charCodeAt(1) << 8) + (d.charCodeAt(2) << 16) + (d.charCodeAt(3) << 24); }; - var seed$1 = seed.length ? seed : /* array */[0]; + var seed$1 = seed.length ? seed : /* int array */[0]; var l = seed$1.length; for(var i = 0; i<= 54; ++i){ - s[1][i] = i; + s[0][i] = i; } var accu = "x"; for(var i$1 = 0 ,i_finish = 54 + Pervasives.max(55, l); i$1<= i_finish; ++i$1){ var j = i$1 % 55; var k = i$1 % l; accu = combine(accu, seed$1[k]); - s[1][j] = (s[1][j] ^ extract(accu)) & 1073741823; + s[0][j] = (s[0][j] ^ extract(accu)) & 1073741823; } - s[2] = 0; + s[1] = 0; return /* () */0; } @@ -66,18 +65,17 @@ function copy(s) { } function bits(s) { - s[2] = (s[2] + 1) % 55; - var curval = s[1][s[2]]; - var newval = s[1][(s[2] + 24) % 55] + (curval ^ (curval >>> 25) & 31); + s[1] = (s[1] + 1) % 55; + var curval = s[0][s[1]]; + var newval = s[0][(s[1] + 24) % 55] + (curval ^ (curval >>> 25) & 31); var newval30 = newval & 1073741823; - s[1][s[2]] = newval30; + s[0][s[1]] = newval30; return newval30; } function $$int(s, bound) { if (bound > 1073741823 || bound <= 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Random.int" ]; @@ -102,7 +100,6 @@ function $$int(s, bound) { function int32(s, bound) { if (bound <= 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Random.int32" ]; @@ -129,7 +126,6 @@ function int32(s, bound) { function int64(s, bound) { if (bound <= 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Random.int64" ]; @@ -175,8 +171,7 @@ function bool(s) { return +((bits(s) & 1) === 0); } -var $$default = [ - /* record */0, +var $$default = /* record */[ /* array */[ 987910699, 495797812, @@ -270,7 +265,7 @@ function full_init$1(seed) { } function init(seed) { - return full_init($$default, /* array */[seed]); + return full_init($$default, /* int array */[seed]); } function self_init() { @@ -286,7 +281,6 @@ function set_state(s) { } var State = [ - 0, make, make_self_init, copy, diff --git a/jscomp/stdlib/scanf.js b/jscomp/stdlib/scanf.js index aa48c1c497..6ebd6f7c9a 100644 --- a/jscomp/stdlib/scanf.js +++ b/jscomp/stdlib/scanf.js @@ -18,20 +18,20 @@ var null_char = /* "\000" */0; function next_char(ib) { try { - var c = Caml_curry.app1(ib[7], /* () */0); - ib[2] = c; - ib[3] = /* true */1; - ++ ib[4]; + var c = Caml_curry.app1(ib[6], /* () */0); + ib[1] = c; + ib[2] = /* true */1; + ++ ib[3]; if (c === /* "\n" */10) { - ++ ib[5]; + ++ ib[4]; } return c; } catch (exn){ if (exn === Caml_builtin_exceptions.End_of_file) { - ib[2] = null_char; - ib[3] = /* false */0; - ib[1] = /* true */1; + ib[1] = null_char; + ib[2] = /* false */0; + ib[0] = /* true */1; return null_char; } else { @@ -41,8 +41,8 @@ function next_char(ib) { } function peek_char(ib) { - if (ib[3]) { - return ib[2]; + if (ib[2]) { + return ib[1]; } else { return next_char(ib); @@ -51,7 +51,7 @@ function peek_char(ib) { function checked_peek_char(ib) { var c = peek_char(ib); - if (ib[1]) { + if (ib[0]) { throw Caml_builtin_exceptions.End_of_file; } return c; @@ -59,15 +59,15 @@ function checked_peek_char(ib) { function end_of_input(ib) { peek_char(ib); - return ib[1]; + return ib[0]; } function beginning_of_input(ib) { - return +(ib[4] === 0); + return +(ib[3] === 0); } function name_of_input(ib) { - var match = ib[9]; + var match = ib[8]; if (typeof match === "number") { if (match) { return "unnamed function"; @@ -76,45 +76,44 @@ function name_of_input(ib) { return "unnamed character string"; } } - else if (match[0]) { + else if (match.tag) { return "unnamed pervasives input channel"; } else { - return match[1]; + return match[0]; } } function char_count(ib) { - if (ib[3]) { - return ib[4] - 1; + if (ib[2]) { + return ib[3] - 1; } else { - return ib[4]; + return ib[3]; } } function token(ib) { - var tokbuf = ib[8]; + var tokbuf = ib[7]; var tok = Buffer.contents(tokbuf); - tokbuf[2] = 0; - ++ ib[6]; + tokbuf[1] = 0; + ++ ib[5]; return tok; } function ignore_char(width, ib) { var width$1 = width - 1; - ib[3] = /* false */0; + ib[2] = /* false */0; return width$1; } function store_char(width, ib, c) { - Buffer.add_char(ib[8], c); + Buffer.add_char(ib[7], c); return ignore_char(width, ib); } function create(iname, next) { - return [ - /* record */0, + return /* record */[ /* false */0, null_char, /* false */0, @@ -128,18 +127,15 @@ function create(iname, next) { } function from_string(s) { - var i = [ - 0, - 0 - ]; + var i = [0]; var len = s.length; var next = function () { - if (i[1] >= len) { + if (i[0] >= len) { throw Caml_builtin_exceptions.End_of_file; } else { - var c = s.charCodeAt(i[1]); - ++ i[1]; + var c = s.charCodeAt(i[0]); + ++ i[0]; return c; } }; @@ -150,10 +146,7 @@ function from_function(param) { return create(/* From_function */1, param); } -var file_buffer_size = [ - 0, - 1024 -]; +var file_buffer_size = [1024]; function scan_close_at_end(ic) { Caml_primitive.caml_ml_close_channel(ic); @@ -165,37 +158,28 @@ function scan_raise_at_end() { } function from_ic(scan_close_ic, iname, ic) { - var len = file_buffer_size[1]; + var len = file_buffer_size[0]; var buf = Caml_string.caml_create_string(len); - var i = [ - 0, - 0 - ]; - var lim = [ - 0, - 0 - ]; - var eof = [ - 0, - /* false */0 - ]; + var i = [0]; + var lim = [0]; + var eof = [/* false */0]; var next = function () { - if (i[1] < lim[1]) { - var c = buf[i[1]]; - ++ i[1]; + if (i[0] < lim[0]) { + var c = buf[i[0]]; + ++ i[0]; return c; } - else if (eof[1]) { + else if (eof[0]) { throw Caml_builtin_exceptions.End_of_file; } else { - lim[1] = Pervasives.input(ic, buf, 0, len); - if (lim[1]) { - i[1] = 1; + lim[0] = Pervasives.input(ic, buf, 0, len); + if (lim[0]) { + i[0] = 1; return buf[0]; } else { - eof[1] = /* true */1; + eof[0] = /* true */1; return Caml_curry.app1(scan_close_ic, ic); } } @@ -203,11 +187,12 @@ function from_ic(scan_close_ic, iname, ic) { return create(iname, next); } -var stdin = from_ic(scan_raise_at_end, [ - /* From_file */0, - "-", - Pervasives.stdin - ], Pervasives.stdin); +var stdin = from_ic(scan_raise_at_end, /* From_file */{ + 0: "-", + 1: Pervasives.stdin, + length: 2, + tag: 0 + }, Pervasives.stdin); function open_in(fname) { if (fname === "-") { @@ -215,11 +200,12 @@ function open_in(fname) { } else { var ic = Pervasives.open_in(fname); - return from_ic(scan_close_at_end, [ - /* From_file */0, - fname, - ic - ], ic); + return from_ic(scan_close_at_end, /* From_file */{ + 0: fname, + 1: ic, + length: 2, + tag: 0 + }, ic); } } @@ -229,37 +215,34 @@ function open_in_bin(fname) { } else { var ic = Pervasives.open_in_bin(fname); - return from_ic(scan_close_at_end, [ - /* From_file */0, - fname, - ic - ], ic); + return from_ic(scan_close_at_end, /* From_file */{ + 0: fname, + 1: ic, + length: 2, + tag: 0 + }, ic); } } -var memo = [ - 0, - /* [] */0 -]; +var memo = [/* [] */0]; function memo_from_ic(scan_close_ic, ic) { try { - return List.assq(ic, memo[1]); + return List.assq(ic, memo[0]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - var ib = from_ic(scan_close_ic, [ - /* From_channel */1, - ic - ], ic); - memo[1] = [ - /* :: */0, - [ - /* tuple */0, + var ib = from_ic(scan_close_ic, /* From_channel */{ + 0: ic, + length: 1, + tag: 1 + }, ic); + memo[0] = /* :: */[ + /* tuple */[ ic, ib ], - memo[1] + memo[0] ]; return ib; } @@ -274,89 +257,100 @@ function from_channel(param) { } function close_in(ib) { - var match = ib[9]; + var match = ib[8]; if (typeof match === "number") { return /* () */0; } - else if (match[0]) { - return Caml_primitive.caml_ml_close_channel(match[1]); + else if (match.tag) { + return Caml_primitive.caml_ml_close_channel(match[0]); } else { - return Caml_primitive.caml_ml_close_channel(match[2]); + return Caml_primitive.caml_ml_close_channel(match[1]); } } -var Scan_failure = [ - 248, - "Scanf.Scan_failure", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Scan_failure = { + 0: "Scanf.Scan_failure", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function bad_input_escape(c) { - var s = Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "illegal escape character ", - [ - /* Caml_char */1, - /* End_of_format */0 - ] - ], - "illegal escape character %C" - ]), c); + var s = Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "illegal escape character ", + 1: /* Caml_char */{ + 0: /* End_of_format */0, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + 1: "illegal escape character %C", + length: 2, + tag: 0 + }), c); throw [ - 0, Scan_failure, s ]; } function bad_token_length(message) { - var s = Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "scanning of ", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - " failed: the specified length was too short for token", - /* End_of_format */0 - ] - ] - ], - "scanning of %s failed: the specified length was too short for token" - ]), message); + var s = Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "scanning of ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " failed: the specified length was too short for token", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "scanning of %s failed: the specified length was too short for token", + length: 2, + tag: 0 + }), message); throw [ - 0, Scan_failure, s ]; } function character_mismatch_err(c, ci) { - return Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "looking for ", - [ - /* Caml_char */1, - [ - /* String_literal */11, - ", found ", - [ - /* Caml_char */1, - /* End_of_format */0 - ] - ] - ] - ], - "looking for %C, found %C" - ]), c, ci); + return Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "looking for ", + 1: /* Caml_char */{ + 0: /* String_literal */{ + 0: ", found ", + 1: /* Caml_char */{ + 0: /* End_of_format */0, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + 1: "looking for %C, found %C", + length: 2, + tag: 0 + }), c, ci); } function check_char(ib, _c) { @@ -366,7 +360,7 @@ function check_char(ib, _c) { var ib$1 = ib; while(true) { var c$1 = peek_char(ib$1); - if (ib$1[1]) { + if (ib$1[0]) { return 0; } else { @@ -376,7 +370,7 @@ function check_char(ib, _c) { return /* () */0; } else { - ib$1[3] = /* false */0; + ib$1[2] = /* false */0; continue ; } @@ -385,7 +379,7 @@ function check_char(ib, _c) { return /* () */0; } else { - ib$1[3] = /* false */0; + ib$1[2] = /* false */0; continue ; } @@ -395,19 +389,18 @@ function check_char(ib, _c) { else { var ci = checked_peek_char(ib); if (ci === c) { - ib[3] = /* false */0; + ib[2] = /* false */0; return /* () */0; } else if (ci !== 13) { var s = character_mismatch_err(c, ci); throw [ - 0, Scan_failure, s ]; } else if (c === /* "\n" */10) { - ib[3] = /* false */0; + ib[2] = /* false */0; _c = /* "\n" */10; continue ; @@ -415,7 +408,6 @@ function check_char(ib, _c) { else { var s$1 = character_mismatch_err(c, ci); throw [ - 0, Scan_failure, s$1 ]; @@ -436,21 +428,23 @@ function token_bool(ib) { case "true" : return /* true */1; default: - var s$1 = Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "invalid boolean ", - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "invalid boolean %S" - ]), s); + var s$1 = Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "invalid boolean ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "invalid boolean %S", + length: 2, + tag: 0 + }), s); throw [ - 0, Scan_failure, s$1 ]; @@ -514,10 +508,8 @@ function token_int_literal(conv, ib) { } if (exit === 1) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "scanf.ml", 507, 11 @@ -542,7 +534,7 @@ function scan_decimal_digits(_width, ib) { var width = _width; if (width) { var c = peek_char(ib); - if (ib[1]) { + if (ib[0]) { return width; } else if (c >= 58) { @@ -576,24 +568,27 @@ function scan_decimal_digits_plus(width, ib) { if (width) { var c = checked_peek_char(ib); if (c > 57 || c < 48) { - var s = Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "character ", - [ - /* Caml_char */1, - [ - /* String_literal */11, - " is not a decimal digit", - /* End_of_format */0 - ] - ] - ], - "character %C is not a decimal digit" - ]), c); + var s = Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "character ", + 1: /* Caml_char */{ + 0: /* String_literal */{ + 0: " is not a decimal digit", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + 1: "character %C is not a decimal digit", + length: 2, + tag: 0 + }), c); throw [ - 0, Scan_failure, s ]; @@ -617,7 +612,7 @@ function scan_digits_plus(basis, digitp, width, ib) { var width$1 = _width; if (width$1) { var c$1 = peek_char(ib); - if (ib[1]) { + if (ib[0]) { return width$1; } else if (Caml_curry.app1(digitp, c$1)) { @@ -640,32 +635,37 @@ function scan_digits_plus(basis, digitp, width, ib) { }; } else { - var s = Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "character ", - [ - /* Caml_char */1, - [ - /* String_literal */11, - " is not a valid ", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - " digit", - /* End_of_format */0 - ] - ] - ] - ] - ], - "character %C is not a valid %s digit" - ]), c, basis); + var s = Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "character ", + 1: /* Caml_char */{ + 0: /* String_literal */{ + 0: " is not a valid ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " digit", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + 1: "character %C is not a valid %s digit", + length: 2, + tag: 0 + }), c, basis); throw [ - 0, Scan_failure, s ]; @@ -773,7 +773,7 @@ function scan_int_conv(conv, width, ib) { var width$4 = store_char(width$3, ib$2, c); if (width$4) { var c$1 = peek_char(ib$2); - if (ib$2[1]) { + if (ib$2[0]) { return width$4; } else if (c$1 >= 99) { @@ -845,10 +845,8 @@ function scan_int_conv(conv, width, ib) { } if (exit === 1) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "scanf.ml", 674, 9 @@ -861,7 +859,7 @@ function scan_int_conv(conv, width, ib) { function scan_frac_part(width, ib) { if (width) { var c = peek_char(ib); - if (ib[1] || c > 57 || c < 48) { + if (ib[0] || c > 57 || c < 48) { return width; } else { @@ -876,7 +874,7 @@ function scan_frac_part(width, ib) { function scan_exp_part(width, ib) { if (width) { var c = peek_char(ib); - if (ib[1] || c !== 69 && c !== 101) { + if (ib[0] || c !== 69 && c !== 101) { return width; } else { @@ -897,16 +895,14 @@ function scan_float(width, precision, ib) { var width$1 = scan_int_part(width, ib); if (width$1) { var c = peek_char(ib); - if (ib[1]) { - return [ - /* tuple */0, + if (ib[0]) { + return /* tuple */[ width$1, precision ]; } else if (c !== 46) { - return [ - /* tuple */0, + return /* tuple */[ scan_exp_part(width$1, ib), precision ]; @@ -915,16 +911,14 @@ function scan_float(width, precision, ib) { var width$2 = store_char(width$1, ib, c); var precision$1 = Pervasives.min(width$2, precision); var width$3 = width$2 - (precision$1 - scan_frac_part(precision$1, ib)); - return [ - /* tuple */0, + return /* tuple */[ scan_exp_part(width$3, ib), precision$1 ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ width$1, precision ]; @@ -935,9 +929,8 @@ function scan_caml_float(width, precision, ib) { var width$1 = scan_optionally_signed_decimal_int(width, ib); if (width$1) { var c = peek_char(ib); - if (ib[1]) { + if (ib[0]) { throw [ - 0, Scan_failure, "no dot or exponent part found in float token" ]; @@ -947,7 +940,6 @@ function scan_caml_float(width, precision, ib) { if (switcher > 32 || switcher < 0) { if (switcher !== -23) { throw [ - 0, Scan_failure, "no dot or exponent part found in float token" ]; @@ -964,7 +956,6 @@ function scan_caml_float(width, precision, ib) { } else { throw [ - 0, Scan_failure, "no dot or exponent part found in float token" ]; @@ -973,7 +964,6 @@ function scan_caml_float(width, precision, ib) { } else { throw [ - 0, Scan_failure, "no dot or exponent part found in float token" ]; @@ -986,12 +976,12 @@ function scan_string(stp, width, ib) { var width$1 = _width; if (width$1) { var c = peek_char(ib); - if (ib[1]) { + if (ib[0]) { return width$1; } else if (stp) { - if (c === stp[1]) { - ib[3] = /* false */0; + if (c === stp[0]) { + ib[2] = /* false */0; return width$1; } else { @@ -1065,26 +1055,30 @@ function char_for_backslash(c) { function char_for_decimal_code(c0, c1, c2) { var c = 100 * (c0 - /* "0" */48) + 10 * (c1 - /* "0" */48) + (c2 - /* "0" */48); if (c < 0 || c > 255) { - var s = Caml_curry.app3(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "bad character decimal encoding \\", - [ - /* Char */0, - [ - /* Char */0, - [ - /* Char */0, - /* End_of_format */0 - ] - ] - ] - ], - "bad character decimal encoding \\%c%c%c" - ]), c0, c1, c2); + var s = Caml_curry.app3(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "bad character decimal encoding \\", + 1: /* Char */{ + 0: /* Char */{ + 0: /* Char */{ + 0: /* End_of_format */0, + length: 1, + tag: 0 + }, + length: 1, + tag: 0 + }, + length: 1, + tag: 0 + }, + length: 2, + tag: 11 + }, + 1: "bad character decimal encoding \\%c%c%c", + length: 2, + tag: 0 + }), c0, c1, c2); throw [ - 0, Scan_failure, s ]; @@ -1109,23 +1103,26 @@ function hexadecimal_value_of_char(c) { function char_for_hexadecimal_code(c1, c2) { var c = 16 * hexadecimal_value_of_char(c1) + hexadecimal_value_of_char(c2); if (c < 0 || c > 255) { - var s = Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "bad character hexadecimal encoding \\", - [ - /* Char */0, - [ - /* Char */0, - /* End_of_format */0 - ] - ] - ], - "bad character hexadecimal encoding \\%c%c" - ]), c1, c2); + var s = Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "bad character hexadecimal encoding \\", + 1: /* Char */{ + 0: /* Char */{ + 0: /* End_of_format */0, + length: 1, + tag: 0 + }, + length: 1, + tag: 0 + }, + length: 2, + tag: 11 + }, + 1: "bad character hexadecimal encoding \\%c%c", + length: 2, + tag: 0 + }), c1, c2); throw [ - 0, Scan_failure, s ]; @@ -1138,27 +1135,30 @@ function char_for_hexadecimal_code(c1, c2) { function check_next_char(message, width, ib) { if (width) { var c = peek_char(ib); - if (ib[1]) { + if (ib[0]) { var message$1 = message; - var s = Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "scanning of ", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - " failed: premature end of file occurred before end of token", - /* End_of_format */0 - ] - ] - ], - "scanning of %s failed: premature end of file occurred before end of token" - ]), message$1); + var s = Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "scanning of ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: " failed: premature end of file occurred before end of token", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "scanning of %s failed: premature end of file occurred before end of token", + length: 2, + tag: 0 + }), message$1); throw [ - 0, Scan_failure, s ]; @@ -1281,7 +1281,6 @@ function scan_caml_char(width, ib) { if (c !== 39) { var s = character_mismatch_err(/* "'" */39, c); throw [ - 0, Scan_failure, s ]; @@ -1295,7 +1294,6 @@ function scan_caml_char(width, ib) { if (c !== 39) { var s = character_mismatch_err(/* "'" */39, c); throw [ - 0, Scan_failure, s ]; @@ -1363,7 +1361,6 @@ function scan_caml_string(width, ib) { if (c !== 34) { var s = character_mismatch_err(/* "\"" */34, c); throw [ - 0, Scan_failure, s ]; @@ -1378,24 +1375,27 @@ function scan_bool(ib) { var m; if (c !== 102) { if (c !== 116) { - var s = Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "the character ", - [ - /* Caml_char */1, - [ - /* String_literal */11, - " cannot start a boolean", - /* End_of_format */0 - ] - ] - ], - "the character %C cannot start a boolean" - ]), c); + var s = Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "the character ", + 1: /* Caml_char */{ + 0: /* String_literal */{ + 0: " cannot start a boolean", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 1, + tag: 1 + }, + length: 2, + tag: 11 + }, + 1: "the character %C cannot start a boolean", + length: 2, + tag: 0 + }), c); throw [ - 0, Scan_failure, s ]; @@ -1415,7 +1415,7 @@ function scan_chars_in_char_set(char_set, scan_indic, width, ib) { while(true) { var i = _i; var c = peek_char(ib); - if (i > 0 && !ib[1] && CamlinternalFormat.is_in_char_set(char_set, c) && c !== stp) { + if (i > 0 && !ib[0] && CamlinternalFormat.is_in_char_set(char_set, c) && c !== stp) { store_char(Pervasives.max_int, ib, c); _i = i - 1; continue ; @@ -1427,21 +1427,20 @@ function scan_chars_in_char_set(char_set, scan_indic, width, ib) { }; }; if (scan_indic) { - var c = scan_indic[1]; + var c = scan_indic[0]; scan_chars(width, c); - if (ib[1]) { + if (ib[0]) { return 0; } else { var ci = peek_char(ib); if (c === ci) { - ib[3] = /* false */0; + ib[2] = /* false */0; return /* () */0; } else { var s = character_mismatch_err(c, ci); throw [ - 0, Scan_failure, s ]; @@ -1456,12 +1455,12 @@ function scan_chars_in_char_set(char_set, scan_indic, width, ib) { function scanf_bad_input(ib, x) { var exit = 0; var s; - if (x[1] === Scan_failure) { - s = x[2]; + if (x[0] === Scan_failure) { + s = x[1]; exit = 1; } - else if (x[1] === Caml_builtin_exceptions.Failure) { - s = x[2]; + else if (x[0] === Caml_builtin_exceptions.Failure) { + s = x[1]; exit = 1; } else { @@ -1469,31 +1468,35 @@ function scanf_bad_input(ib, x) { } if (exit === 1) { var i = char_count(ib); - var s$1 = Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "scanf: bad input at char number ", - [ - /* Int */4, - /* Int_i */3, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ": ", - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ] - ] - ], - "scanf: bad input at char number %i: %S" - ]), i, s); + var s$1 = Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "scanf: bad input at char number ", + 1: /* Int */{ + 0: /* Int_i */3, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ": ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "scanf: bad input at char number %i: %S", + length: 2, + tag: 0 + }), i, s); throw [ - 0, Scan_failure, s$1 ]; @@ -1504,18 +1507,18 @@ function scanf_bad_input(ib, x) { function get_counter(ib, counter) { switch (counter) { case 0 : - return ib[5]; + return ib[4]; case 1 : return char_count(ib); case 2 : - return ib[6]; + return ib[5]; } } function width_of_pad_opt(pad_opt) { if (pad_opt) { - return pad_opt[1]; + return pad_opt[0]; } else { return Pervasives.max_int; @@ -1524,8 +1527,7 @@ function width_of_pad_opt(pad_opt) { function stopper_of_formatting_lit(fmting) { if (fmting === /* Escaped_percent */6) { - return [ - /* tuple */0, + return /* tuple */[ /* "%" */37, "" ]; @@ -1534,8 +1536,7 @@ function stopper_of_formatting_lit(fmting) { var str = CamlinternalFormat.string_of_formatting_lit(fmting); var stp = str.charCodeAt(1); var sub_str = $$String.sub(str, 2, str.length - 2); - return [ - /* tuple */0, + return /* tuple */[ stp, sub_str ]; @@ -1549,39 +1550,40 @@ function take_format_readers(k, _fmt) { return Caml_curry.app1(k, /* Nil */0); } else { - switch (fmt[0]) { + switch (fmt.tag | 0) { case 4 : case 5 : case 6 : case 7 : case 8 : - _fmt = fmt[4]; + _fmt = fmt[3]; continue ; case 14 : - return take_fmtty_format_readers(k, CamlinternalFormatBasics.erase_rel(CamlinternalFormat.symm(fmt[2])), fmt[3]); + return take_fmtty_format_readers(k, CamlinternalFormatBasics.erase_rel(CamlinternalFormat.symm(fmt[1])), fmt[2]); case 18 : - var match = fmt[1]; - if (match[0]) { - _fmt = CamlinternalFormatBasics.concat_fmt(match[1][1], fmt[2]); + var match = fmt[0]; + if (match.tag) { + _fmt = CamlinternalFormatBasics.concat_fmt(match[0][0], fmt[1]); continue ; } else { - _fmt = CamlinternalFormatBasics.concat_fmt(match[1][1], fmt[2]); + _fmt = CamlinternalFormatBasics.concat_fmt(match[0][0], fmt[1]); continue ; } break; case 19 : - var fmt_rest = fmt[1]; + var fmt_rest = fmt[0]; return (function(fmt_rest){ return function (reader) { var new_k = function (readers_rest) { - return Caml_curry.app1(k, [ - /* Cons */0, - reader, - readers_rest - ]); + return Caml_curry.app1(k, /* Cons */{ + 0: reader, + 1: readers_rest, + length: 2, + tag: 0 + }); }; return take_format_readers(new_k, fmt_rest); } @@ -1592,7 +1594,7 @@ function take_format_readers(k, _fmt) { case 12 : case 17 : case 21 : - _fmt = fmt[2]; + _fmt = fmt[1]; continue ; case 0 : case 1 : @@ -1601,23 +1603,24 @@ function take_format_readers(k, _fmt) { case 15 : case 16 : case 22 : - _fmt = fmt[1]; + _fmt = fmt[0]; continue ; case 23 : var k$1 = k; - var ign = fmt[1]; - var fmt$1 = fmt[2]; + var ign = fmt[0]; + var fmt$1 = fmt[1]; if (typeof ign === "number") { switch (ign) { case 3 : return (function(k$1,fmt$1){ return function (reader) { var new_k = function (readers_rest) { - return Caml_curry.app1(k$1, [ - /* Cons */0, - reader, - readers_rest - ]); + return Caml_curry.app1(k$1, /* Cons */{ + 0: reader, + 1: readers_rest, + length: 2, + tag: 0 + }); }; return take_format_readers(new_k, fmt$1); } @@ -1631,9 +1634,9 @@ function take_format_readers(k, _fmt) { } } else { - switch (ign[0]) { + switch (ign.tag | 0) { case 8 : - return take_fmtty_format_readers(k$1, ign[2], fmt$1); + return take_fmtty_format_readers(k$1, ign[1], fmt$1); case 0 : case 1 : case 2 : @@ -1651,7 +1654,7 @@ function take_format_readers(k, _fmt) { case 13 : case 20 : case 24 : - _fmt = fmt[3]; + _fmt = fmt[2]; continue ; } @@ -1666,13 +1669,13 @@ function take_fmtty_format_readers(k, _fmtty, fmt) { return take_format_readers(k, fmt); } else { - switch (fmtty[0]) { + switch (fmtty.tag | 0) { case 8 : - _fmtty = fmtty[2]; + _fmtty = fmtty[1]; continue ; case 9 : - var ty = CamlinternalFormat.trans(CamlinternalFormat.symm(fmtty[1]), fmtty[2]); - _fmtty = CamlinternalFormatBasics.concat_fmtty(ty, fmtty[3]); + var ty = CamlinternalFormat.trans(CamlinternalFormat.symm(fmtty[0]), fmtty[1]); + _fmtty = CamlinternalFormatBasics.concat_fmtty(ty, fmtty[2]); continue ; case 0 : case 1 : @@ -1685,32 +1688,34 @@ function take_fmtty_format_readers(k, _fmtty, fmt) { case 10 : case 11 : case 12 : - _fmtty = fmtty[1]; + _fmtty = fmtty[0]; continue ; case 13 : - var fmt_rest = fmtty[1]; + var fmt_rest = fmtty[0]; return (function(fmt_rest){ return function (reader) { var new_k = function (readers_rest) { - return Caml_curry.app1(k, [ - /* Cons */0, - reader, - readers_rest - ]); + return Caml_curry.app1(k, /* Cons */{ + 0: reader, + 1: readers_rest, + length: 2, + tag: 0 + }); }; return take_fmtty_format_readers(new_k, fmt_rest, fmt); } }(fmt_rest)); case 14 : - var fmt_rest$1 = fmtty[1]; + var fmt_rest$1 = fmtty[0]; return (function(fmt_rest$1){ return function (reader) { var new_k = function (readers_rest) { - return Caml_curry.app1(k, [ - /* Cons */0, - reader, - readers_rest - ]); + return Caml_curry.app1(k, /* Cons */{ + 0: reader, + 1: readers_rest, + length: 2, + tag: 0 + }); }; return take_fmtty_format_readers(new_k, fmt_rest$1, fmt); } @@ -1728,70 +1733,64 @@ function make_scanf(ib, _fmt, readers) { return /* Nil */0; } else { - switch (fmt[0]) { + switch (fmt.tag | 0) { case 0 : scan_char(0, ib); var c = token_char(ib); - return [ - /* Cons */0, - c, - make_scanf(ib, fmt[1], readers) - ]; + return /* Cons */{ + 0: c, + 1: make_scanf(ib, fmt[0], readers), + length: 2, + tag: 0 + }; case 1 : scan_caml_char(0, ib); var c$1 = token_char(ib); - return [ - /* Cons */0, - c$1, - make_scanf(ib, fmt[1], readers) - ]; + return /* Cons */{ + 0: c$1, + 1: make_scanf(ib, fmt[0], readers), + length: 2, + tag: 0 + }; case 2 : - var rest = fmt[2]; - var pad = fmt[1]; + var rest = fmt[1]; + var pad = fmt[0]; var exit = 0; if (typeof rest === "number") { exit = 1; } else { - switch (rest[0]) { + switch (rest.tag | 0) { case 17 : - var match = stopper_of_formatting_lit(rest[1]); - var stp = match[1]; + var match = stopper_of_formatting_lit(rest[0]); + var stp = match[0]; var scan = (function(stp){ return function (width, _, ib) { - return scan_string([ - /* Some */0, - stp - ], width, ib); + return scan_string(/* Some */[stp], width, ib); } }(stp)); - var str_rest_001 = match[2]; - var str_rest_002 = rest[2]; - var str_rest = [ - /* String_literal */11, - str_rest_001, - str_rest_002 - ]; + var str_rest_000 = match[1]; + var str_rest_001 = rest[1]; + var str_rest = /* String_literal */{ + 0: str_rest_000, + 1: str_rest_001, + length: 2, + tag: 11 + }; return pad_prec_scanf(ib, str_rest, readers, pad, /* No_precision */0, scan, token); case 18 : - var match$1 = rest[1]; - if (match$1[0]) { + var match$1 = rest[0]; + if (match$1.tag) { var scan$1 = function (width, _, ib) { - return scan_string([ - /* Some */0, - /* "[" */91 - ], width, ib); + return scan_string(/* Some */[/* "[" */91], width, ib); }; - return pad_prec_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$1[1][1], rest[2]), readers, pad, /* No_precision */0, scan$1, token); + return pad_prec_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$1[0][0], rest[1]), readers, pad, /* No_precision */0, scan$1, token); } else { var scan$2 = function (width, _, ib) { - return scan_string([ - /* Some */0, - /* "{" */123 - ], width, ib); + return scan_string(/* Some */[/* "{" */123], width, ib); }; - return pad_prec_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$1[1][1], rest[2]), readers, pad, /* No_precision */0, scan$2, token); + return pad_prec_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$1[0][0], rest[1]), readers, pad, /* No_precision */0, scan$2, token); } break; default: @@ -1809,79 +1808,79 @@ function make_scanf(ib, _fmt, readers) { var scan$4 = function (width, _, ib) { return scan_caml_string(width, ib); }; - return pad_prec_scanf(ib, fmt[2], readers, fmt[1], /* No_precision */0, scan$4, token); + return pad_prec_scanf(ib, fmt[1], readers, fmt[0], /* No_precision */0, scan$4, token); case 4 : - var c$2 = CamlinternalFormat.char_of_iconv(fmt[1]); + var c$2 = CamlinternalFormat.char_of_iconv(fmt[0]); var scan$5 = (function(c$2){ return function (width, _, ib) { return scan_int_conv(c$2, width, ib); } }(c$2)); - return pad_prec_scanf(ib, fmt[4], readers, fmt[2], fmt[3], scan$5, (function(c$2){ + return pad_prec_scanf(ib, fmt[3], readers, fmt[1], fmt[2], scan$5, (function(c$2){ return function (param) { return Caml_format.caml_int_of_string(token_int_literal(c$2, param)); } }(c$2))); case 5 : - var c$3 = CamlinternalFormat.char_of_iconv(fmt[1]); + var c$3 = CamlinternalFormat.char_of_iconv(fmt[0]); var scan$6 = (function(c$3){ return function (width, _, ib) { return scan_int_conv(c$3, width, ib); } }(c$3)); - return pad_prec_scanf(ib, fmt[4], readers, fmt[2], fmt[3], scan$6, (function(c$3){ + return pad_prec_scanf(ib, fmt[3], readers, fmt[1], fmt[2], scan$6, (function(c$3){ return function (param) { return Caml_format.caml_int32_of_string(token_int_literal(c$3, param)); } }(c$3))); case 6 : - var c$4 = CamlinternalFormat.char_of_iconv(fmt[1]); + var c$4 = CamlinternalFormat.char_of_iconv(fmt[0]); var scan$7 = (function(c$4){ return function (width, _, ib) { return scan_int_conv(c$4, width, ib); } }(c$4)); - return pad_prec_scanf(ib, fmt[4], readers, fmt[2], fmt[3], scan$7, (function(c$4){ + return pad_prec_scanf(ib, fmt[3], readers, fmt[1], fmt[2], scan$7, (function(c$4){ return function (param) { return Caml_format.caml_nativeint_of_string(token_int_literal(c$4, param)); } }(c$4))); case 7 : - var c$5 = CamlinternalFormat.char_of_iconv(fmt[1]); + var c$5 = CamlinternalFormat.char_of_iconv(fmt[0]); var scan$8 = (function(c$5){ return function (width, _, ib) { return scan_int_conv(c$5, width, ib); } }(c$5)); - return pad_prec_scanf(ib, fmt[4], readers, fmt[2], fmt[3], scan$8, (function(c$5){ + return pad_prec_scanf(ib, fmt[3], readers, fmt[1], fmt[2], scan$8, (function(c$5){ return function (param) { return Caml_primitive.caml_int64_of_string(token_int_literal(c$5, param)); } }(c$5))); case 8 : - if (fmt[1] >= 15) { - return pad_prec_scanf(ib, fmt[4], readers, fmt[2], fmt[3], scan_caml_float, token_float); + if (fmt[0] >= 15) { + return pad_prec_scanf(ib, fmt[3], readers, fmt[1], fmt[2], scan_caml_float, token_float); } else { - return pad_prec_scanf(ib, fmt[4], readers, fmt[2], fmt[3], scan_float, token_float); + return pad_prec_scanf(ib, fmt[3], readers, fmt[1], fmt[2], scan_float, token_float); } case 9 : scan_bool(ib); var b = token_bool(ib); - return [ - /* Cons */0, - b, - make_scanf(ib, fmt[1], readers) - ]; + return /* Cons */{ + 0: b, + 1: make_scanf(ib, fmt[0], readers), + length: 2, + tag: 0 + }; case 10 : if (end_of_input(ib)) { - _fmt = fmt[1]; + _fmt = fmt[0]; continue ; } else { throw [ - 0, Scan_failure, "end of input not found" ]; @@ -1890,141 +1889,139 @@ function make_scanf(ib, _fmt, readers) { case 11 : $$String.iter(function (param) { return check_char(ib, param); - }, fmt[1]); - _fmt = fmt[2]; + }, fmt[0]); + _fmt = fmt[1]; continue ; case 12 : - check_char(ib, fmt[1]); - _fmt = fmt[2]; + check_char(ib, fmt[0]); + _fmt = fmt[1]; continue ; case 13 : - scan_caml_string(width_of_pad_opt(fmt[1]), ib); + scan_caml_string(width_of_pad_opt(fmt[0]), ib); var s = token(ib); var fmt$1; try { - fmt$1 = CamlinternalFormat.format_of_string_fmtty(s, fmt[2]); + fmt$1 = CamlinternalFormat.format_of_string_fmtty(s, fmt[1]); } catch (exn){ - if (exn[1] === Caml_builtin_exceptions.Failure) { + if (exn[0] === Caml_builtin_exceptions.Failure) { throw [ - 0, Scan_failure, - exn[2] + exn[1] ]; } else { throw exn; } } - return [ - /* Cons */0, - fmt$1, - make_scanf(ib, fmt[3], readers) - ]; + return /* Cons */{ + 0: fmt$1, + 1: make_scanf(ib, fmt[2], readers), + length: 2, + tag: 0 + }; case 14 : - var fmtty = fmt[2]; - scan_caml_string(width_of_pad_opt(fmt[1]), ib); + var fmtty = fmt[1]; + scan_caml_string(width_of_pad_opt(fmt[0]), ib); var s$1 = token(ib); var match$2; try { var match$3 = CamlinternalFormat.fmt_ebb_of_string(/* None */0, s$1); var match$4 = CamlinternalFormat.fmt_ebb_of_string(/* None */0, s$1); - match$2 = [ - /* tuple */0, - CamlinternalFormat.type_format(match$3[1], CamlinternalFormatBasics.erase_rel(fmtty)), - CamlinternalFormat.type_format(match$4[1], CamlinternalFormatBasics.erase_rel(CamlinternalFormat.symm(fmtty))) + match$2 = /* tuple */[ + CamlinternalFormat.type_format(match$3[0], CamlinternalFormatBasics.erase_rel(fmtty)), + CamlinternalFormat.type_format(match$4[0], CamlinternalFormatBasics.erase_rel(CamlinternalFormat.symm(fmtty))) ]; } catch (exn$1){ - if (exn$1[1] === Caml_builtin_exceptions.Failure) { + if (exn$1[0] === Caml_builtin_exceptions.Failure) { throw [ - 0, Scan_failure, - exn$1[2] + exn$1[1] ]; } else { throw exn$1; } } - return [ - /* Cons */0, - [ - /* Format */0, - match$2[1], - s$1 - ], - make_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$2[2], fmt[3]), readers) - ]; + return /* Cons */{ + 0: /* Format */{ + 0: match$2[0], + 1: s$1, + length: 2, + tag: 0 + }, + 1: make_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$2[1], fmt[2]), readers), + length: 2, + tag: 0 + }; case 15 : throw [ - 0, Caml_builtin_exceptions.Invalid_argument, 'scanf: bad conversion "%a"' ]; case 16 : throw [ - 0, Caml_builtin_exceptions.Invalid_argument, 'scanf: bad conversion "%t"' ]; case 17 : $$String.iter(function (param) { return check_char(ib, param); - }, CamlinternalFormat.string_of_formatting_lit(fmt[1])); - _fmt = fmt[2]; + }, CamlinternalFormat.string_of_formatting_lit(fmt[0])); + _fmt = fmt[1]; continue ; case 18 : - var match$5 = fmt[1]; + var match$5 = fmt[0]; check_char(ib, /* "@" */64); - if (match$5[0]) { + if (match$5.tag) { check_char(ib, /* "[" */91); - _fmt = CamlinternalFormatBasics.concat_fmt(match$5[1][1], fmt[2]); + _fmt = CamlinternalFormatBasics.concat_fmt(match$5[0][0], fmt[1]); continue ; } else { check_char(ib, /* "{" */123); - _fmt = CamlinternalFormatBasics.concat_fmt(match$5[1][1], fmt[2]); + _fmt = CamlinternalFormatBasics.concat_fmt(match$5[0][0], fmt[1]); continue ; } break; case 19 : - var x = Caml_curry.app1(readers[1], ib); - return [ - /* Cons */0, - x, - make_scanf(ib, fmt[1], readers[2]) - ]; + var x = Caml_curry.app1(readers[0], ib); + return /* Cons */{ + 0: x, + 1: make_scanf(ib, fmt[0], readers[1]), + length: 2, + tag: 0 + }; case 20 : - var rest$1 = fmt[3]; - var char_set = fmt[2]; - var width_opt = fmt[1]; + var rest$1 = fmt[2]; + var char_set = fmt[1]; + var width_opt = fmt[0]; var exit$1 = 0; if (typeof rest$1 === "number") { exit$1 = 1; } - else if (rest$1[0] === 17) { - var match$6 = stopper_of_formatting_lit(rest$1[1]); + else if (rest$1.tag === 17) { + var match$6 = stopper_of_formatting_lit(rest$1[0]); var width = width_of_pad_opt(width_opt); - scan_chars_in_char_set(char_set, [ - /* Some */0, - match$6[1] - ], width, ib); + scan_chars_in_char_set(char_set, /* Some */[match$6[0]], width, ib); var s$2 = token(ib); - var str_rest_001$1 = match$6[2]; - var str_rest_002$1 = rest$1[2]; - var str_rest$1 = [ - /* String_literal */11, - str_rest_001$1, - str_rest_002$1 - ]; - return [ - /* Cons */0, - s$2, - make_scanf(ib, str_rest$1, readers) - ]; + var str_rest_000$1 = match$6[1]; + var str_rest_001$1 = rest$1[1]; + var str_rest$1 = /* String_literal */{ + 0: str_rest_000$1, + 1: str_rest_001$1, + length: 2, + tag: 11 + }; + return /* Cons */{ + 0: s$2, + 1: make_scanf(ib, str_rest$1, readers), + length: 2, + tag: 0 + }; } else { exit$1 = 1; @@ -2033,39 +2030,40 @@ function make_scanf(ib, _fmt, readers) { var width$1 = width_of_pad_opt(width_opt); scan_chars_in_char_set(char_set, /* None */0, width$1, ib); var s$3 = token(ib); - return [ - /* Cons */0, - s$3, - make_scanf(ib, rest$1, readers) - ]; + return /* Cons */{ + 0: s$3, + 1: make_scanf(ib, rest$1, readers), + length: 2, + tag: 0 + }; } break; case 21 : - var count = get_counter(ib, fmt[1]); - return [ - /* Cons */0, - count, - make_scanf(ib, fmt[2], readers) - ]; + var count = get_counter(ib, fmt[0]); + return /* Cons */{ + 0: count, + 1: make_scanf(ib, fmt[1], readers), + length: 2, + tag: 0 + }; case 22 : var c$6 = checked_peek_char(ib); - return [ - /* Cons */0, - c$6, - make_scanf(ib, fmt[1], readers) - ]; + return /* Cons */{ + 0: c$6, + 1: make_scanf(ib, fmt[0], readers), + length: 2, + tag: 0 + }; case 23 : - var match$7 = CamlinternalFormat.param_format_of_ignored_format(fmt[1], fmt[2]); - var match$8 = make_scanf(ib, match$7[1], readers); + var match$7 = CamlinternalFormat.param_format_of_ignored_format(fmt[0], fmt[1]); + var match$8 = make_scanf(ib, match$7[0], readers); if (match$8) { - return match$8[2]; + return match$8[1]; } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "scanf.ml", 1258, 13 @@ -2075,7 +2073,6 @@ function make_scanf(ib, _fmt, readers) { break; case 24 : throw [ - 0, Caml_builtin_exceptions.Invalid_argument, 'scanf: bad conversion "%?" (custom converter)' ]; @@ -2090,7 +2087,6 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { if (typeof prec === "number") { if (prec !== 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, 'scanf: bad conversion "%*"' ]; @@ -2098,36 +2094,36 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { else { Caml_curry.app3(scan, Pervasives.max_int, Pervasives.max_int, ib); var x = Caml_curry.app1(token, ib); - return [ - /* Cons */0, - x, - make_scanf(ib, fmt, readers) - ]; + return /* Cons */{ + 0: x, + 1: make_scanf(ib, fmt, readers), + length: 2, + tag: 0 + }; } } else { - Caml_curry.app3(scan, Pervasives.max_int, prec[1], ib); + Caml_curry.app3(scan, Pervasives.max_int, prec[0], ib); var x$1 = Caml_curry.app1(token, ib); - return [ - /* Cons */0, - x$1, - make_scanf(ib, fmt, readers) - ]; + return /* Cons */{ + 0: x$1, + 1: make_scanf(ib, fmt, readers), + length: 2, + tag: 0 + }; } } - else if (pad[0]) { + else if (pad.tag) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, 'scanf: bad conversion "%*"' ]; } - else if (pad[1] !== 0) { - var w = pad[2]; + else if (pad[0] !== 0) { + var w = pad[1]; if (typeof prec === "number") { if (prec !== 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, 'scanf: bad conversion "%*"' ]; @@ -2135,26 +2131,27 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { else { Caml_curry.app3(scan, w, Pervasives.max_int, ib); var x$2 = Caml_curry.app1(token, ib); - return [ - /* Cons */0, - x$2, - make_scanf(ib, fmt, readers) - ]; + return /* Cons */{ + 0: x$2, + 1: make_scanf(ib, fmt, readers), + length: 2, + tag: 0 + }; } } else { - Caml_curry.app3(scan, w, prec[1], ib); + Caml_curry.app3(scan, w, prec[0], ib); var x$3 = Caml_curry.app1(token, ib); - return [ - /* Cons */0, - x$3, - make_scanf(ib, fmt, readers) - ]; + return /* Cons */{ + 0: x$3, + 1: make_scanf(ib, fmt, readers), + length: 2, + tag: 0 + }; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, 'scanf: bad conversion "%-"' ]; @@ -2162,40 +2159,43 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { } function kscanf(ib, ef, param) { - var str = param[2]; - var fmt = param[1]; + var str = param[1]; + var fmt = param[0]; var k = function (readers, f) { - Buffer.reset(ib[8]); + Buffer.reset(ib[7]); var match; try { - match = [ - /* Args */0, - make_scanf(ib, fmt, readers) - ]; + match = /* Args */{ + 0: make_scanf(ib, fmt, readers), + length: 1, + tag: 0 + }; } catch (exc){ - if (exc[1] === Scan_failure) { - match = [ - /* Exc */1, - exc - ]; + if (exc[0] === Scan_failure) { + match = /* Exc */{ + 0: exc, + length: 1, + tag: 1 + }; } - else if (exc[1] === Caml_builtin_exceptions.Failure) { - match = [ - /* Exc */1, - exc - ]; + else if (exc[0] === Caml_builtin_exceptions.Failure) { + match = /* Exc */{ + 0: exc, + length: 1, + tag: 1 + }; } else if (exc === Caml_builtin_exceptions.End_of_file) { - match = [ - /* Exc */1, - exc - ]; + match = /* Exc */{ + 0: exc, + length: 1, + tag: 1 + }; } - else if (exc[1] === Caml_builtin_exceptions.Invalid_argument) { - var s = exc[2] + (' in format "' + ($$String.escaped(str) + '"')); + else if (exc[0] === Caml_builtin_exceptions.Invalid_argument) { + var s = exc[1] + (' in format "' + ($$String.escaped(str) + '"')); throw [ - 0, Caml_builtin_exceptions.Invalid_argument, s ]; @@ -2204,18 +2204,18 @@ function kscanf(ib, ef, param) { throw exc; } } - if (match[0]) { - return Caml_curry.app2(ef, ib, match[1]); + if (match.tag) { + return Caml_curry.app2(ef, ib, match[0]); } else { var _f = f; - var _args = match[1]; + var _args = match[0]; while(true) { var args = _args; var f$1 = _f; if (args) { - _args = args[2]; - _f = Caml_curry.app1(f$1, args[1]); + _args = args[1]; + _f = Caml_curry.app1(f$1, args[0]); continue ; } @@ -2260,11 +2260,10 @@ function bscanf_format(ib, format, f) { $js = CamlinternalFormat.format_of_string_format(str, format); } catch (exn){ - if (exn[1] === Caml_builtin_exceptions.Failure) { + if (exn[0] === Caml_builtin_exceptions.Failure) { throw [ - 0, Scan_failure, - exn[2] + exn[1] ]; } else { @@ -2300,24 +2299,26 @@ function format_from_string(s, fmt) { } function unescaped(s) { - return Caml_curry.app1(sscanf('"' + (s + '"'), [ - /* Format */0, - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* Flush */10, - /* End_of_format */0 - ] - ], - "%S%!" - ]), function (x) { + return Caml_curry.app1(sscanf('"' + (s + '"'), /* Format */{ + 0: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* Flush */{ + 0: /* End_of_format */0, + length: 1, + tag: 10 + }, + length: 2, + tag: 3 + }, + 1: "%S%!", + length: 2, + tag: 0 + }), function (x) { return x; }); } var Scanning = [ - 0, stdin, open_in, open_in_bin, diff --git a/jscomp/stdlib/set.js b/jscomp/stdlib/set.js index 480632a44a..4120c70034 100644 --- a/jscomp/stdlib/set.js +++ b/jscomp/stdlib/set.js @@ -8,40 +8,40 @@ var List = require("./list"); function Make(funarg) { var height = function (param) { if (param) { - return param[4]; + return param[3]; } else { return 0; } }; var create = function (l, v, r) { - var hl = l ? l[4] : 0; - var hr = r ? r[4] : 0; - return [ - /* Node */0, - l, - v, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + var hl = l ? l[3] : 0; + var hr = r ? r[3] : 0; + return /* Node */{ + 0: l, + 1: v, + 2: r, + 3: hl >= hr ? hl + 1 : hr + 1, + length: 4, + tag: 0 + }; }; var bal = function (l, v, r) { - var hl = l ? l[4] : 0; - var hr = r ? r[4] : 0; + var hl = l ? l[3] : 0; + var hr = r ? r[3] : 0; if (hl > hr + 2) { if (l) { - var lr = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } else if (lr) { - return create(create(ll, lv, lr[1]), lr[2], create(lr[3], v, r)); + return create(create(ll, lv, lr[0]), lr[1], create(lr[2], v, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; @@ -49,7 +49,6 @@ function Make(funarg) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; @@ -57,18 +56,17 @@ function Make(funarg) { } else if (hr > hl + 2) { if (r) { - var rr = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } else if (rl) { - return create(create(l, v, rl[1]), rl[2], create(rl[3], rv, rr)); + return create(create(l, v, rl[0]), rl[1], create(rl[2], rv, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; @@ -76,28 +74,28 @@ function Make(funarg) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; } } else { - return [ - /* Node */0, - l, - v, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: v, + 2: r, + 3: hl >= hr ? hl + 1 : hr + 1, + length: 4, + tag: 0 + }; } }; var add = function (x, t) { if (t) { - var r = t[3]; - var v = t[2]; - var l = t[1]; - var c = Caml_curry.app2(funarg[1], x, v); + var r = t[2]; + var v = t[1]; + var l = t[0]; + var c = Caml_curry.app2(funarg[0], x, v); if (c) { if (c < 0) { return bal(add(x, l), v, r); @@ -111,27 +109,29 @@ function Make(funarg) { } } else { - return [ - /* Node */0, - /* Empty */0, - x, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }; } }; var singleton = function (x) { - return [ - /* Node */0, - /* Empty */0, - x, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }; }; var add_min_element = function (v, param) { if (param) { - return bal(add_min_element(v, param[1]), param[2], param[3]); + return bal(add_min_element(v, param[0]), param[1], param[2]); } else { return singleton(v); @@ -139,7 +139,7 @@ function Make(funarg) { }; var add_max_element = function (v, param) { if (param) { - return bal(param[1], param[2], add_max_element(v, param[3])); + return bal(param[0], param[1], add_max_element(v, param[2])); } else { return singleton(v); @@ -148,13 +148,13 @@ function Make(funarg) { var join = function (l, v, r) { if (l) { if (r) { - var rh = r[4]; - var lh = l[4]; + var rh = r[3]; + var lh = l[3]; if (lh > rh + 2) { - return bal(l[1], l[2], join(l[3], v, r)); + return bal(l[0], l[1], join(l[2], v, r)); } else if (rh > lh + 2) { - return bal(join(l, v, r[1]), r[2], r[3]); + return bal(join(l, v, r[0]), r[1], r[2]); } else { return create(l, v, r); @@ -172,14 +172,14 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return param[2]; + return param[1]; } } else { @@ -191,14 +191,14 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var r = param[3]; + var r = param[2]; if (r) { _param = r; continue ; } else { - return param[2]; + return param[1]; } } else { @@ -208,17 +208,16 @@ function Make(funarg) { }; var remove_min_elt = function (param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal(remove_min_elt(l), param[2], param[3]); + return bal(remove_min_elt(l), param[1], param[2]); } else { - return param[3]; + return param[2]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.remove_min_elt" ]; @@ -239,33 +238,30 @@ function Make(funarg) { }; var split = function (x, param) { if (param) { - var r = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_curry.app2(funarg[1], x, v); + var r = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(funarg[0], x, v); if (c) { if (c < 0) { var match = split(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join(match[3], v, r) + join(match[2], v, r) ]; } else { var match$1 = split(x, r); - return [ - /* tuple */0, - join(l, v, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join(l, v, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, /* true */1, r @@ -273,8 +269,7 @@ function Make(funarg) { } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* false */0, /* Empty */0 @@ -294,9 +289,9 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var c = Caml_curry.app2(funarg[1], x, param[2]); + var c = Caml_curry.app2(funarg[0], x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[3]; + _param = c < 0 ? param[0] : param[2]; continue ; } @@ -311,10 +306,10 @@ function Make(funarg) { }; var remove = function (x, param) { if (param) { - var r = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_curry.app2(funarg[1], x, v); + var r = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(funarg[0], x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, r); @@ -346,17 +341,17 @@ function Make(funarg) { var union = function (s1, s2) { if (s1) { if (s2) { - var h2 = s2[4]; - var v2 = s2[2]; - var h1 = s1[4]; - var v1 = s1[2]; + var h2 = s2[3]; + var v2 = s2[1]; + var h1 = s1[3]; + var v1 = s1[1]; if (h1 >= h2) { if (h2 === 1) { return add(v2, s1); } else { var match = split(v1, s2); - return join(union(s1[1], match[1]), v1, union(s1[3], match[3])); + return join(union(s1[0], match[0]), v1, union(s1[2], match[2])); } } else if (h1 === 1) { @@ -364,7 +359,7 @@ function Make(funarg) { } else { var match$1 = split(v2, s1); - return join(union(match$1[1], s2[1]), v2, union(match$1[3], s2[3])); + return join(union(match$1[0], s2[0]), v2, union(match$1[2], s2[2])); } } else { @@ -378,16 +373,16 @@ function Make(funarg) { var inter = function (s1, s2) { if (s1) { if (s2) { - var r1 = s1[3]; - var v1 = s1[2]; - var l1 = s1[1]; + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; var match = split(v1, s2); - var l2 = match[1]; - if (match[2] !== 0) { - return join(inter(l1, l2), v1, inter(r1, match[3])); + var l2 = match[0]; + if (match[1] !== 0) { + return join(inter(l1, l2), v1, inter(r1, match[2])); } else { - return concat(inter(l1, l2), inter(r1, match[3])); + return concat(inter(l1, l2), inter(r1, match[2])); } } else { @@ -401,16 +396,16 @@ function Make(funarg) { var diff = function (s1, s2) { if (s1) { if (s2) { - var r1 = s1[3]; - var v1 = s1[2]; - var l1 = s1[1]; + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; var match = split(v1, s2); - var l2 = match[1]; - if (match[2] !== 0) { - return concat(diff(l1, l2), diff(r1, match[3])); + var l2 = match[0]; + if (match[1] !== 0) { + return concat(diff(l1, l2), diff(r1, match[2])); } else { - return join(diff(l1, l2), v1, diff(r1, match[3])); + return join(diff(l1, l2), v1, diff(r1, match[2])); } } else { @@ -426,13 +421,14 @@ function Make(funarg) { var e = _e; var s = _s; if (s) { - _e = [ - /* More */0, - s[2], - s[3], - e - ]; - _s = s[1]; + _e = /* More */{ + 0: s[1], + 1: s[2], + 2: e, + length: 3, + tag: 0 + }; + _s = s[0]; continue ; } @@ -449,13 +445,13 @@ function Make(funarg) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_curry.app2(funarg[1], e1[1], e2[1]); + var c = Caml_curry.app2(funarg[0], e1[0], e2[0]); if (c !== 0) { return c; } else { - _e2 = cons_enum(e2[2], e2[3]); - _e1 = cons_enum(e1[2], e1[3]); + _e2 = cons_enum(e2[1], e2[2]); + _e1 = cons_enum(e1[1], e1[2]); continue ; } @@ -481,21 +477,22 @@ function Make(funarg) { var s1 = _s1; if (s1) { if (s2) { - var r2 = s2[3]; - var l2 = s2[1]; - var r1 = s1[3]; - var v1 = s1[2]; - var l1 = s1[1]; - var c = Caml_curry.app2(funarg[1], v1, s2[2]); + var r2 = s2[2]; + var l2 = s2[0]; + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; + var c = Caml_curry.app2(funarg[0], v1, s2[1]); if (c) { if (c < 0) { - if (subset([ - /* Node */0, - l1, - v1, - /* Empty */0, - 0 - ], l2)) { + if (subset(/* Node */{ + 0: l1, + 1: v1, + 2: /* Empty */0, + 3: 0, + length: 4, + tag: 0 + }, l2)) { _s1 = r1; continue ; @@ -504,13 +501,14 @@ function Make(funarg) { return /* false */0; } } - else if (subset([ - /* Node */0, - /* Empty */0, - v1, - r1, - 0 - ], r2)) { + else if (subset(/* Node */{ + 0: /* Empty */0, + 1: v1, + 2: r1, + 3: 0, + length: 4, + tag: 0 + }, r2)) { _s1 = l1; continue ; @@ -542,9 +540,9 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - iter(f, param[1]); - Caml_curry.app1(f, param[2]); - _param = param[3]; + iter(f, param[0]); + Caml_curry.app1(f, param[1]); + _param = param[2]; continue ; } @@ -558,8 +556,8 @@ function Make(funarg) { var accu = _accu; var s = _s; if (s) { - _accu = Caml_curry.app2(f, s[2], fold(f, s[1], accu)); - _s = s[3]; + _accu = Caml_curry.app2(f, s[1], fold(f, s[0], accu)); + _s = s[2]; continue ; } @@ -572,9 +570,9 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[2])) { - if (for_all(p, param[1])) { - _param = param[3]; + if (Caml_curry.app1(p, param[1])) { + if (for_all(p, param[0])) { + _param = param[2]; continue ; } @@ -595,14 +593,14 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[2])) { + if (Caml_curry.app1(p, param[1])) { return /* true */1; } - else if (exists(p, param[1])) { + else if (exists(p, param[0])) { return /* true */1; } else { - _param = param[3]; + _param = param[2]; continue ; } @@ -614,10 +612,10 @@ function Make(funarg) { }; var filter = function (p, param) { if (param) { - var v = param[2]; - var l$prime = filter(p, param[1]); + var v = param[1]; + var l$prime = filter(p, param[0]); var pv = Caml_curry.app1(p, v); - var r$prime = filter(p, param[3]); + var r$prime = filter(p, param[2]); if (pv) { return join(l$prime, v, r$prime); } @@ -631,32 +629,29 @@ function Make(funarg) { }; var partition = function (p, param) { if (param) { - var v = param[2]; - var match = partition(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pv = Caml_curry.app1(p, v); - var match$1 = partition(p, param[3]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition(p, param[2]); + var rf = match$1[1]; + var rt = match$1[0]; if (pv) { - return [ - /* tuple */0, + return /* tuple */[ join(lt, v, rt), concat(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat(lt, rt), join(lf, v, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -664,7 +659,7 @@ function Make(funarg) { }; var cardinal = function (param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[3]); + return cardinal(param[0]) + 1 + cardinal(param[2]); } else { return 0; @@ -675,11 +670,10 @@ function Make(funarg) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - param[2], - elements_aux(accu, param[3]) + _param = param[0]; + _accu = /* :: */[ + param[1], + elements_aux(accu, param[2]) ]; continue ; @@ -696,10 +690,10 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var v = param[2]; - var c = Caml_curry.app2(funarg[1], x, v); + var v = param[1]; + var c = Caml_curry.app2(funarg[0], x, v); if (c) { - _param = c < 0 ? param[1] : param[3]; + _param = c < 0 ? param[0] : param[2]; continue ; } @@ -714,20 +708,20 @@ function Make(funarg) { }; var of_list = function (l) { if (l) { - var match = l[2]; - var x0 = l[1]; + var match = l[1]; + var x0 = l[0]; if (match) { - var match$1 = match[2]; - var x1 = match[1]; + var match$1 = match[1]; + var x1 = match[0]; if (match$1) { - var match$2 = match$1[2]; - var x2 = match$1[1]; + var match$2 = match$1[1]; + var x2 = match$1[0]; if (match$2) { - var match$3 = match$2[2]; - var x3 = match$2[1]; + var match$3 = match$2[1]; + var x3 = match$2[0]; if (match$3) { - if (match$3[2]) { - var l$1 = List.sort_uniq(funarg[1], l); + if (match$3[1]) { + var l$1 = List.sort_uniq(funarg[0], l); var sub = function (n, l) { var exit = 0; if (n > 3 || n < 0) { @@ -736,23 +730,22 @@ function Make(funarg) { else { switch (n) { case 0 : - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, l ]; case 1 : if (l) { - return [ - /* tuple */0, - [ - /* Node */0, - /* Empty */0, - l[1], - /* Empty */0, - 1 - ], - l[2] + return /* tuple */[ + /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + l[1] ]; } else { @@ -761,24 +754,25 @@ function Make(funarg) { break; case 2 : if (l) { - var match = l[2]; + var match = l[1]; if (match) { - return [ - /* tuple */0, - [ - /* Node */0, - [ - /* Node */0, - /* Empty */0, - l[1], - /* Empty */0, - 1 - ], - match[1], - /* Empty */0, - 2 - ], - match[2] + return /* tuple */[ + /* Node */{ + 0: /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 1: match[0], + 2: /* Empty */0, + 3: 2, + length: 4, + tag: 0 + }, + match[1] ]; } else { @@ -791,32 +785,34 @@ function Make(funarg) { break; case 3 : if (l) { - var match$1 = l[2]; + var match$1 = l[1]; if (match$1) { - var match$2 = match$1[2]; + var match$2 = match$1[1]; if (match$2) { - return [ - /* tuple */0, - [ - /* Node */0, - [ - /* Node */0, - /* Empty */0, - l[1], - /* Empty */0, - 1 - ], - match$1[1], - [ - /* Node */0, - /* Empty */0, - match$2[1], - /* Empty */0, - 1 - ], - 2 - ], - match$2[2] + return /* tuple */[ + /* Node */{ + 0: /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 1: match$1[0], + 2: /* Node */{ + 0: /* Empty */0, + 1: match$2[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 3: 2, + length: 4, + tag: 0 + }, + match$2[1] ]; } else { @@ -837,21 +833,18 @@ function Make(funarg) { if (exit === 1) { var nl = n / 2 | 0; var match$3 = sub(nl, l); - var l$1 = match$3[2]; + var l$1 = match$3[1]; if (l$1) { - var match$4 = sub(n - nl - 1, l$1[2]); - return [ - /* tuple */0, - create(match$3[1], l$1[1], match$4[1]), - match$4[2] + var match$4 = sub(n - nl - 1, l$1[1]); + return /* tuple */[ + create(match$3[0], l$1[0], match$4[0]), + match$4[1] ]; } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "set.ml", 372, 18 @@ -861,10 +854,10 @@ function Make(funarg) { } }; - return sub(List.length(l$1), l$1)[1]; + return sub(List.length(l$1), l$1)[0]; } else { - return add(match$3[1], add(x3, add(x2, add(x1, singleton(x0))))); + return add(match$3[0], add(x3, add(x2, add(x1, singleton(x0))))); } } else { @@ -888,7 +881,6 @@ function Make(funarg) { } }; return [ - 0, empty, is_empty, mem, diff --git a/jscomp/stdlib/sort.js b/jscomp/stdlib/sort.js index 4c2538de62..e7cb9a4971 100644 --- a/jscomp/stdlib/sort.js +++ b/jscomp/stdlib/sort.js @@ -6,21 +6,19 @@ var Caml_curry = require("../runtime/caml_curry"); function merge(order, l1, l2) { if (l1) { - var h1 = l1[1]; + var h1 = l1[0]; if (l2) { - var h2 = l2[1]; + var h2 = l2[0]; if (Caml_curry.app2(order, h1, h2)) { - return [ - /* :: */0, + return /* :: */[ h1, - merge(order, l1[2], l2) + merge(order, l1[1], l2) ]; } else { - return [ - /* :: */0, + return /* :: */[ h2, - merge(order, l1, l2[2]) + merge(order, l1, l2[1]) ]; } } @@ -36,37 +34,30 @@ function merge(order, l1, l2) { function list(order, l) { var initlist = function (param) { if (param) { - var match = param[2]; - var e = param[1]; + var match = param[1]; + var e = param[0]; if (match) { - var e2 = match[1]; - return [ - /* :: */0, - Caml_curry.app2(order, e, e2) ? [ - /* :: */0, + var e2 = match[0]; + return /* :: */[ + Caml_curry.app2(order, e, e2) ? /* :: */[ e, - [ - /* :: */0, + /* :: */[ e2, /* [] */0 ] - ] : [ - /* :: */0, + ] : /* :: */[ e2, - [ - /* :: */0, + /* :: */[ e, /* [] */0 ] ], - initlist(match[2]) + initlist(match[1]) ]; } else { - return [ - /* :: */0, - [ - /* :: */0, + return /* :: */[ + /* :: */[ e, /* [] */0 ], @@ -80,12 +71,11 @@ function list(order, l) { }; var merge2 = function (x) { if (x) { - var match = x[2]; + var match = x[1]; if (match) { - return [ - /* :: */0, - merge(order, x[1], match[1]), - merge2(match[2]) + return /* :: */[ + merge(order, x[0], match[0]), + merge2(match[1]) ]; } else { @@ -100,13 +90,13 @@ function list(order, l) { while(true) { var llist = _llist; if (llist) { - if (llist[2]) { + if (llist[1]) { _llist = merge2(llist); continue ; } else { - return llist[1]; + return llist[0]; } } else { @@ -144,7 +134,6 @@ function array(cmp, arr) { var j = hi - 1; if (!Caml_curry.app2(cmp, pivot, arr[hi]) || !Caml_curry.app2(cmp, arr[lo], pivot)) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Sort.array" ]; diff --git a/jscomp/stdlib/stack.js b/jscomp/stdlib/stack.js index 378e390e8d..5223c79886 100644 --- a/jscomp/stdlib/stack.js +++ b/jscomp/stdlib/stack.js @@ -4,45 +4,39 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); var List = require("./list"); -var Empty = [ - 248, - "Stack.Empty", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Empty = { + 0: "Stack.Empty", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function create() { - return [ - /* record */0, - /* [] */0 - ]; + return /* record */[/* [] */0]; } function clear(s) { - s[1] = /* [] */0; + s[0] = /* [] */0; return /* () */0; } function copy(s) { - return [ - /* record */0, - s[1] - ]; + return /* record */[s[0]]; } function push(x, s) { - s[1] = [ - /* :: */0, + s[0] = /* :: */[ x, - s[1] + s[0] ]; return /* () */0; } function pop(s) { - var match = s[1]; + var match = s[0]; if (match) { - s[1] = match[2]; - return match[1]; + s[0] = match[1]; + return match[0]; } else { throw Empty; @@ -50,9 +44,9 @@ function pop(s) { } function top(s) { - var match = s[1]; + var match = s[0]; if (match) { - return match[1]; + return match[0]; } else { throw Empty; @@ -60,15 +54,15 @@ function top(s) { } function is_empty(s) { - return +(s[1] === /* [] */0); + return +(s[0] === /* [] */0); } function length(s) { - return List.length(s[1]); + return List.length(s[0]); } function iter(f, s) { - return List.iter(f, s[1]); + return List.iter(f, s[0]); } exports.Empty = Empty; diff --git a/jscomp/stdlib/stream.js b/jscomp/stdlib/stream.js index a6dc041f79..ec1ff028a4 100644 --- a/jscomp/stdlib/stream.js +++ b/jscomp/stdlib/stream.js @@ -2,27 +2,28 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var CamlinternalLazy = require("./camlinternalLazy"); var Pervasives = require("./pervasives"); var Caml_curry = require("../runtime/caml_curry"); var List = require("./list"); -var Failure = [ - 248, - "Stream.Failure", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Failure = { + 0: "Stream.Failure", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; -var $$Error = [ - 248, - "Stream.Error", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var $$Error = { + 0: "Stream.Error", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function fill_buff(b) { - b[3] = Pervasives.input(b[1], b[2], 0, b[2].length); - b[4] = 0; + b[2] = Pervasives.input(b[0], b[1], 0, b[1].length); + b[3] = 0; return /* () */0; } @@ -33,19 +34,17 @@ function get_data(count, _d) { return d; } else { - switch (d[0]) { + switch (d.tag | 0) { case 0 : return d; case 1 : - var d2 = d[2]; - var match = get_data(count, d[1]); + var d2 = d[1]; + var match = get_data(count, d[0]); if (typeof match === "number") { if (match) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "stream.ml", 53, 12 @@ -58,12 +57,10 @@ function get_data(count, _d) { } } - else if (match[0]) { + else if (match.tag) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "stream.ml", 53, 12 @@ -71,72 +68,74 @@ function get_data(count, _d) { ]; } else { - return [ - /* Scons */0, - match[1], - [ - /* Sapp */1, - match[2], - d2 - ] - ]; + return /* Scons */{ + 0: match[0], + 1: /* Sapp */{ + 0: match[1], + 1: d2, + length: 2, + tag: 1 + }, + length: 2, + tag: 0 + }; } break; case 2 : - var f = d[1]; - var tag = Caml_obj_runtime.caml_obj_tag(f); - _d = tag === 250 ? f[1] : ( + var f = d[0]; + var tag = f.tag | 0; + _d = tag === 250 ? f[0] : ( tag === 246 ? CamlinternalLazy.force_lazy_block(f) : f ); continue ; case 3 : - var g = d[1]; - var match$1 = g[1]; + var g = d[0]; + var match$1 = g[0]; if (match$1) { - var match$2 = match$1[1]; + var match$2 = match$1[0]; if (match$2) { - g[1] = /* None */0; - return [ - /* Scons */0, - match$2[1], - d - ]; + g[0] = /* None */0; + return /* Scons */{ + 0: match$2[0], + 1: d, + length: 2, + tag: 0 + }; } else { return /* Sempty */0; } } else { - var match$3 = Caml_curry.app1(g[2], count); + var match$3 = Caml_curry.app1(g[1], count); if (match$3) { - return [ - /* Scons */0, - match$3[1], - d - ]; + return /* Scons */{ + 0: match$3[0], + 1: d, + length: 2, + tag: 0 + }; } else { - g[1] = [ - /* Some */0, - /* None */0 - ]; + g[0] = /* Some */[/* None */0]; return /* Sempty */0; } } break; case 4 : - var b = d[1]; - if (b[4] >= b[3]) { + var b = d[0]; + if (b[3] >= b[2]) { fill_buff(b); } - if (b[3]) { - var r = b[2][b[4]]; - ++ b[4]; - return [ - /* Scons */0, - r, - d - ]; + if (b[2]) { + var r = b[1][b[3]]; + ++ b[3]; + return /* Scons */{ + 0: r, + 1: d, + length: 2, + tag: 0 + }; } else { return /* Sempty */0; @@ -150,26 +149,21 @@ function get_data(count, _d) { function peek(s) { while(true) { - var match = s[2]; + var match = s[1]; if (typeof match === "number") { return /* None */0; } else { - switch (match[0]) { + switch (match.tag | 0) { case 0 : - return [ - /* Some */0, - match[1] - ]; + return /* Some */[match[0]]; case 1 : - var d = get_data(s[1], s[2]); + var d = get_data(s[0], s[1]); if (typeof d === "number") { if (d) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "stream.ml", 82, 12 @@ -180,12 +174,10 @@ function peek(s) { return /* None */0; } } - else if (d[0]) { + else if (d.tag) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "stream.ml", 82, 12 @@ -194,45 +186,36 @@ function peek(s) { } else { s[1] = d; - return [ - /* Some */0, - d[1] - ]; + return /* Some */[d[0]]; } break; case 2 : - var f = match[1]; - var tag = Caml_obj_runtime.caml_obj_tag(f); - var d$1 = tag === 250 ? f[1] : ( + var f = match[0]; + var tag = f.tag | 0; + var d$1 = tag === 250 ? f[0] : ( tag === 246 ? CamlinternalLazy.force_lazy_block(f) : f ); s[1] = d$1; continue ; case 3 : - var g = match[1]; - var match$1 = g[1]; + var g = match[0]; + var match$1 = g[0]; if (match$1) { - return match$1[1]; + return match$1[0]; } else { - var x = Caml_curry.app1(g[2], s[1]); - g[1] = [ - /* Some */0, - x - ]; + var x = Caml_curry.app1(g[1], s[0]); + g[0] = /* Some */[x]; return x; } break; case 4 : - var b = match[1]; - if (b[4] >= b[3]) { + var b = match[0]; + if (b[3] >= b[2]) { fill_buff(b); } - if (b[3]) { - return [ - /* Some */0, - b[2][b[4]] - ]; + if (b[2]) { + return /* Some */[b[1][b[3]]]; } else { s[1] = /* Sempty */0; @@ -246,23 +229,23 @@ function peek(s) { function junk(s) { while(true) { - var match = s[2]; + var match = s[1]; var exit = 0; if (typeof match === "number") { exit = 1; } else { - switch (match[0]) { + switch (match.tag | 0) { case 0 : - ++ s[1]; - s[1] = match[2]; + ++ s[0]; + s[1] = match[1]; return /* () */0; case 3 : - var g = match[1]; - var match$1 = g[1]; + var g = match[0]; + var match$1 = g[0]; if (match$1) { - ++ s[1]; - g[1] = /* None */0; + ++ s[0]; + g[0] = /* None */0; return /* () */0; } else { @@ -270,9 +253,9 @@ function junk(s) { } break; case 4 : - var b = match[1]; - ++ s[1]; - ++ b[4]; + var b = match[0]; + ++ s[0]; + ++ b[3]; return /* () */0; default: exit = 1; @@ -294,39 +277,36 @@ function junk(s) { function nget(n, s) { if (n <= 0) { - return [ - /* tuple */0, + return /* tuple */[ /* [] */0, - s[2], + s[1], 0 ]; } else { var match = peek(s); if (match) { - var a = match[1]; + var a = match[0]; junk(s); var match$1 = nget(n - 1, s); - return [ - /* tuple */0, - [ - /* :: */0, + return /* tuple */[ + /* :: */[ a, - match$1[1] + match$1[0] ], - [ - /* Scons */0, - a, - match$1[2] - ], - match$1[3] + 1 + /* Scons */{ + 0: a, + 1: match$1[1], + length: 2, + tag: 0 + }, + match$1[2] + 1 ]; } else { - return [ - /* tuple */0, + return /* tuple */[ /* [] */0, - s[2], + s[1], 0 ]; } @@ -335,16 +315,16 @@ function nget(n, s) { function npeek(n, s) { var match = nget(n, s); - s[1] -= match[3]; - s[1] = match[2]; - return match[1]; + s[0] -= match[2]; + s[1] = match[1]; + return match[0]; } function next(s) { var match = peek(s); if (match) { junk(s); - return match[1]; + return match[0]; } else { throw Failure; @@ -367,7 +347,7 @@ function iter(f, strm) { var match = peek(strm); if (match) { junk(strm); - Caml_curry.app1(f, match[1]); + Caml_curry.app1(f, match[0]); _param = /* () */0; continue ; @@ -379,47 +359,40 @@ function iter(f, strm) { } function from(f) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Sgen */3, - [ - /* record */0, + /* Sgen */{ + 0: /* record */[ /* None */0, f - ] - ] + ], + length: 1, + tag: 3 + } ]; } function of_list(l) { - return [ - /* record */0, + return /* record */[ 0, List.fold_right(function (x, l) { - return [ - /* Scons */0, - x, - l - ]; + return /* Scons */{ + 0: x, + 1: l, + length: 2, + tag: 0 + }; }, l, /* Sempty */0) ]; } function of_string(s) { - var count = [ - 0, - 0 - ]; + var count = [0]; return from(function () { - var c = count[1]; + var c = count[0]; if (c < s.length) { - ++ count[1]; - return [ - /* Some */0, - s.charCodeAt(c) - ]; + ++ count[0]; + return /* Some */[s.charCodeAt(c)]; } else { return /* None */0; @@ -428,18 +401,12 @@ function of_string(s) { } function of_bytes(s) { - var count = [ - 0, - 0 - ]; + var count = [0]; return from(function () { - var c = count[1]; + var c = count[0]; if (c < s.length) { - ++ count[1]; - return [ - /* Some */0, - s[c] - ]; + ++ count[0]; + return /* Some */[s[c]]; } else { return /* None */0; @@ -448,139 +415,145 @@ function of_bytes(s) { } function of_channel(ic) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Sbuffio */4, - [ - /* record */0, + /* Sbuffio */{ + 0: /* record */[ ic, new Array(4096), 0, 0 - ] - ] + ], + length: 1, + tag: 4 + } ]; } function iapp(i, s) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Sapp */1, - i[2], - s[2] - ] + /* Sapp */{ + 0: i[1], + 1: s[1], + length: 2, + tag: 1 + } ]; } function icons(i, s) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Scons */0, - i, - s[2] - ] + /* Scons */{ + 0: i, + 1: s[1], + length: 2, + tag: 0 + } ]; } function ising(i) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Scons */0, - i, - /* Sempty */0 - ] + /* Scons */{ + 0: i, + 1: /* Sempty */0, + length: 2, + tag: 0 + } ]; } function lapp(f, s) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Slazy */2, - [ - 246, - function () { - return [ - /* Sapp */1, - Caml_curry.app1(f, /* () */0)[2], - s[2] - ]; - } - ] - ] + /* Slazy */{ + 0: { + 0: function () { + return /* Sapp */{ + 0: Caml_curry.app1(f, /* () */0)[1], + 1: s[1], + length: 2, + tag: 1 + }; + }, + length: 1, + tag: 246 + }, + length: 1, + tag: 2 + } ]; } function lcons(f, s) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Slazy */2, - [ - 246, - function () { - return [ - /* Scons */0, - Caml_curry.app1(f, /* () */0), - s[2] - ]; - } - ] - ] + /* Slazy */{ + 0: { + 0: function () { + return /* Scons */{ + 0: Caml_curry.app1(f, /* () */0), + 1: s[1], + length: 2, + tag: 0 + }; + }, + length: 1, + tag: 246 + }, + length: 1, + tag: 2 + } ]; } function lsing(f) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Slazy */2, - [ - 246, - function () { - return [ - /* Scons */0, - Caml_curry.app1(f, /* () */0), - /* Sempty */0 - ]; - } - ] - ] + /* Slazy */{ + 0: { + 0: function () { + return /* Scons */{ + 0: Caml_curry.app1(f, /* () */0), + 1: /* Sempty */0, + length: 2, + tag: 0 + }; + }, + length: 1, + tag: 246 + }, + length: 1, + tag: 2 + } ]; } function slazy(f) { - return [ - /* record */0, + return /* record */[ 0, - [ - /* Slazy */2, - [ - 246, - function () { - return Caml_curry.app1(f, /* () */0)[2]; - } - ] - ] + /* Slazy */{ + 0: { + 0: function () { + return Caml_curry.app1(f, /* () */0)[1]; + }, + length: 1, + tag: 246 + }, + length: 1, + tag: 2 + } ]; } function dump(f, s) { Pervasives.print_string("{count = "); - Pervasives.print_int(s[1]); + Pervasives.print_int(s[0]); Pervasives.print_string("; data = "); - dump_data(f, s[2]); + dump_data(f, s[1]); Pervasives.print_string("}"); return Pervasives.print_newline(/* () */0); } @@ -590,18 +563,18 @@ function dump_data(f, param) { return Pervasives.print_string("Sempty"); } else { - switch (param[0]) { + switch (param.tag | 0) { case 0 : Pervasives.print_string("Scons ("); - Caml_curry.app1(f, param[1]); + Caml_curry.app1(f, param[0]); Pervasives.print_string(", "); - dump_data(f, param[2]); + dump_data(f, param[1]); return Pervasives.print_string(")"); case 1 : Pervasives.print_string("Sapp ("); - dump_data(f, param[1]); + dump_data(f, param[0]); Pervasives.print_string(", "); - dump_data(f, param[2]); + dump_data(f, param[1]); return Pervasives.print_string(")"); case 2 : return Pervasives.print_string("Slazy"); @@ -615,11 +588,10 @@ function dump_data(f, param) { } function count(prim) { - return prim[1]; + return prim[0]; } -var sempty = [ - /* record */0, +var sempty = /* record */[ 0, /* Sempty */0 ]; diff --git a/jscomp/stdlib/string.js b/jscomp/stdlib/string.js index 6ff809be71..7ca6cfb043 100644 --- a/jscomp/stdlib/string.js +++ b/jscomp/stdlib/string.js @@ -28,33 +28,24 @@ function sub(s, ofs, len) { function concat(sep, l) { if (l) { - var hd = l[1]; - var num = [ - 0, - 0 - ]; - var len = [ - 0, - 0 - ]; + var hd = l[0]; + var num = [0]; + var len = [0]; List.iter(function (s) { - ++ num[1]; - len[1] += s.length; + ++ num[0]; + len[0] += s.length; return /* () */0; }, l); - var r = Caml_string.caml_create_string(len[1] + sep.length * (num[1] - 1)); + var r = Caml_string.caml_create_string(len[0] + sep.length * (num[0] - 1)); Caml_string.caml_blit_string(hd, 0, r, 0, hd.length); - var pos = [ - 0, - hd.length - ]; + var pos = [hd.length]; List.iter(function (s) { - Caml_string.caml_blit_string(sep, 0, r, pos[1], sep.length); - pos[1] += sep.length; - Caml_string.caml_blit_string(s, 0, r, pos[1], s.length); - pos[1] += s.length; + Caml_string.caml_blit_string(sep, 0, r, pos[0], sep.length); + pos[0] += sep.length; + Caml_string.caml_blit_string(s, 0, r, pos[0], s.length); + pos[0] += s.length; return /* () */0; - }, l[2]); + }, l[1]); return Caml_string.bytes_to_string(r); } else { diff --git a/jscomp/stdlib/sys.js b/jscomp/stdlib/sys.js index fe4a637138..15392adecb 100644 --- a/jscomp/stdlib/sys.js +++ b/jscomp/stdlib/sys.js @@ -6,7 +6,7 @@ var Caml_primitive = require("../runtime/caml_primitive"); var is_js = /* true */1; -var match_002 = []; +var match_001 = /* array */[]; var big_endian = /* false */0; @@ -22,10 +22,7 @@ var max_array_length = 4294967295; var max_string_length = 4294967295; -var interactive = [ - 0, - /* false */0 -]; +var interactive = [/* false */0]; function set_signal(sig_num, sig_beh) { return Caml_primitive.caml_install_signal_handler(sig_num, sig_beh); @@ -33,27 +30,29 @@ function set_signal(sig_num, sig_beh) { var sigint = -6; -var Break = [ - 248, - "Sys.Break", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Break = { + 0: "Sys.Break", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function catch_break(on) { if (on) { - return Caml_primitive.caml_install_signal_handler(sigint, [ - /* Signal_handle */0, - function () { + return Caml_primitive.caml_install_signal_handler(sigint, /* Signal_handle */{ + 0: function () { throw Break; - } - ]); + }, + length: 1, + tag: 0 + }); } else { return Caml_primitive.caml_install_signal_handler(sigint, /* Signal_default */0); } } -var argv = match_002; +var argv = match_001; var executable_name = "cmd"; diff --git a/jscomp/stdlib/weak.js b/jscomp/stdlib/weak.js index a787bb8a5a..0e65668707 100644 --- a/jscomp/stdlib/weak.js +++ b/jscomp/stdlib/weak.js @@ -2,7 +2,7 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("./pervasives"); var Sys = require("./sys"); var Caml_primitive = require("../runtime/caml_primitive"); @@ -17,7 +17,6 @@ function length(x) { function fill(ar, ofs, len, x) { if (ofs < 0 || len < 0 || ofs + len > ar.length - 1) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Weak.fill" ]; @@ -33,29 +32,28 @@ function fill(ar, ofs, len, x) { function Make(H) { var emptybucket = Caml_primitive.caml_weak_create(0); var get_index = function (t, h) { - return (h & Pervasives.max_int) % t[1].length; + return (h & Pervasives.max_int) % t[0].length; }; var limit = 7; var over_limit = 2; var create = function (sz) { var sz$1 = sz < 7 ? 7 : sz; var sz$2 = sz$1 > Sys.max_array_length ? Sys.max_array_length : sz$1; - return [ - /* record */0, + return /* record */[ Caml_array.caml_make_vect(sz$2, emptybucket), - Caml_array.caml_make_vect(sz$2, /* array */[]), + Caml_array.caml_make_vect(sz$2, /* int array */[]), limit, 0, 0 ]; }; var clear = function (t) { - for(var i = 0 ,i_finish = t[1].length - 1; i<= i_finish; ++i){ - t[1][i] = emptybucket; - t[2][i] = /* array */[]; + for(var i = 0 ,i_finish = t[0].length - 1; i<= i_finish; ++i){ + t[0][i] = emptybucket; + t[1][i] = /* int array */[]; } - t[3] = limit; - t[4] = 0; + t[2] = limit; + t[3] = 0; return /* () */0; }; var fold = function (f, t, init) { @@ -72,7 +70,7 @@ function Make(H) { else { var match = Caml_primitive.caml_weak_get(b, i); if (match) { - _accu = Caml_curry.app2(f, match[1], accu); + _accu = Caml_curry.app2(f, match[0], accu); _i = i + 1; continue ; @@ -84,7 +82,7 @@ function Make(H) { } } }; - }, t[1], init); + }, t[0], init); }; var iter = function (f, t) { return $$Array.iter(function (param) { @@ -98,7 +96,7 @@ function Make(H) { else { var match = Caml_primitive.caml_weak_get(b, i); if (match) { - Caml_curry.app1(f, match[1]); + Caml_curry.app1(f, match[0]); _i = i + 1; continue ; @@ -110,7 +108,7 @@ function Make(H) { } } }; - }, t[1]); + }, t[0]); }; var iter_weak = function (f, t) { return $$Array.iteri(function (param, param$1) { @@ -125,7 +123,7 @@ function Make(H) { else { var match = Caml_primitive.caml_weak_check(b, i); if (match !== 0) { - Caml_curry.app3(f, b, t[2][j], i); + Caml_curry.app3(f, b, t[1][j], i); _i = i + 1; continue ; @@ -137,7 +135,7 @@ function Make(H) { } } }; - }, t[1]); + }, t[0]); }; var count_bucket = function (_i, b, _accu) { while(true) { @@ -159,7 +157,7 @@ function Make(H) { var count = function (t) { return $$Array.fold_right(function (param, param$1) { return count_bucket(0, param, param$1); - }, t[1], 0); + }, t[0], 0); }; var next_sz = function (n) { return Pervasives.min((3 * n / 2 | 0) + 3, Sys.max_array_length); @@ -168,8 +166,8 @@ function Make(H) { return ((n - 3) * 2 + 2) / 3 | 0; }; var test_shrink_bucket = function (t) { - var bucket = t[1][t[5]]; - var hbucket = t[2][t[5]]; + var bucket = t[0][t[4]]; + var hbucket = t[1][t[4]]; var len = bucket.length - 1; var prev_len = prev_sz(len); var live = count_bucket(0, bucket, 0); @@ -205,24 +203,24 @@ function Make(H) { }; loop(0, bucket.length - 1 - 1); if (prev_len) { - Caml_obj_runtime.caml_obj_truncate(bucket, prev_len + 1); - Caml_obj_runtime.caml_obj_truncate(hbucket, prev_len); + Caml_obj.caml_obj_truncate(bucket, prev_len + 1); + Caml_obj.caml_obj_truncate(hbucket, prev_len); } else { - t[1][t[5]] = emptybucket; - t[2][t[5]] = /* array */[]; + t[0][t[4]] = emptybucket; + t[1][t[4]] = /* int array */[]; } - if (len > t[3] && prev_len <= t[3]) { - -- t[4]; + if (len > t[2] && prev_len <= t[2]) { + -- t[3]; } } - t[5] = (t[5] + 1) % t[1].length; + t[4] = (t[4] + 1) % t[0].length; return /* () */0; }; var add_aux = function (t, setter, d, h, index) { - var bucket = t[1][index]; - var hashes = t[2][index]; + var bucket = t[0][index]; + var hashes = t[1][index]; var sz = bucket.length - 1; var _i = 0; while(true) { @@ -231,7 +229,6 @@ function Make(H) { var newsz = Pervasives.min((3 * sz / 2 | 0) + 3, Sys.max_array_length - 1); if (newsz <= sz) { throw [ - 0, Caml_builtin_exceptions.Failure, "Weak.Make: hash bucket cannot grow more" ]; @@ -242,17 +239,17 @@ function Make(H) { $$Array.blit(hashes, 0, newhashes, 0, sz); Caml_curry.app3(setter, newbucket, sz, d); newhashes[sz] = h; - t[1][index] = newbucket; - t[2][index] = newhashes; - if (sz <= t[3] && newsz > t[3]) { - ++ t[4]; + t[0][index] = newbucket; + t[1][index] = newhashes; + if (sz <= t[2] && newsz > t[2]) { + ++ t[3]; for(var _i$1 = 0; _i$1<= over_limit; ++_i$1){ test_shrink_bucket(t); } } - if (t[4] > (t[1].length / over_limit | 0)) { + if (t[3] > (t[0].length / over_limit | 0)) { var t$1 = t; - var oldlen = t$1[1].length; + var oldlen = t$1[0].length; var newlen = next_sz(oldlen); if (newlen > oldlen) { var newt = create(newlen); @@ -266,16 +263,16 @@ function Make(H) { } }(newt)); iter_weak(add_weak, t$1); + t$1[0] = newt[0]; t$1[1] = newt[1]; t$1[2] = newt[2]; t$1[3] = newt[3]; - t$1[4] = newt[4]; - t$1[5] = t$1[5] % newt[1].length; + t$1[4] = t$1[4] % newt[0].length; return /* () */0; } else { - t$1[3] = Pervasives.max_int; - t$1[4] = 0; + t$1[2] = Pervasives.max_int; + t$1[3] = 0; return /* () */0; } } @@ -296,19 +293,16 @@ function Make(H) { }; }; var add = function (t, d) { - var h = Caml_curry.app1(H[2], d); + var h = Caml_curry.app1(H[1], d); return add_aux(t, function (prim, prim$1, prim$2) { return Caml_primitive.caml_weak_set(prim, prim$1, prim$2); - }, [ - /* Some */0, - d - ], h, get_index(t, h)); + }, /* Some */[d], h, get_index(t, h)); }; var find_or = function (t, d, ifnotfound) { - var h = Caml_curry.app1(H[2], d); + var h = Caml_curry.app1(H[1], d); var index = get_index(t, h); - var bucket = t[1][index]; - var hashes = t[2][index]; + var bucket = t[0][index]; + var hashes = t[1][index]; var sz = bucket.length - 1; var _i = 0; while(true) { @@ -319,10 +313,10 @@ function Make(H) { else if (h === hashes[i]) { var match = Caml_primitive.caml_weak_get_copy(bucket, i); if (match) { - if (Caml_curry.app2(H[1], match[1], d)) { + if (Caml_curry.app2(H[0], match[0], d)) { var match$1 = Caml_primitive.caml_weak_get(bucket, i); if (match$1) { - return match$1[1]; + return match$1[0]; } else { _i = i + 1; @@ -353,10 +347,7 @@ function Make(H) { return find_or(t, d, function (h, index) { add_aux(t, function (prim, prim$1, prim$2) { return Caml_primitive.caml_weak_set(prim, prim$1, prim$2); - }, [ - /* Some */0, - d - ], h, index); + }, /* Some */[d], h, index); return d; }); }; @@ -366,10 +357,10 @@ function Make(H) { }); }; var find_shadow = function (t, d, iffound, ifnotfound) { - var h = Caml_curry.app1(H[2], d); + var h = Caml_curry.app1(H[1], d); var index = get_index(t, h); - var bucket = t[1][index]; - var hashes = t[2][index]; + var bucket = t[0][index]; + var hashes = t[1][index]; var sz = bucket.length - 1; var _i = 0; while(true) { @@ -380,7 +371,7 @@ function Make(H) { else if (h === hashes[i]) { var match = Caml_primitive.caml_weak_get_copy(bucket, i); if (match) { - if (Caml_curry.app2(H[1], match[1], d)) { + if (Caml_curry.app2(H[0], match[0], d)) { return Caml_curry.app2(iffound, bucket, i); } else { @@ -413,10 +404,10 @@ function Make(H) { }, /* false */0); }; var find_all = function (t, d) { - var h = Caml_curry.app1(H[2], d); + var h = Caml_curry.app1(H[1], d); var index = get_index(t, h); - var bucket = t[1][index]; - var hashes = t[2][index]; + var bucket = t[0][index]; + var hashes = t[1][index]; var sz = bucket.length - 1; var _i = 0; var _accu = /* [] */0; @@ -429,12 +420,11 @@ function Make(H) { else if (h === hashes[i]) { var match = Caml_primitive.caml_weak_get_copy(bucket, i); if (match) { - if (Caml_curry.app2(H[1], match[1], d)) { + if (Caml_curry.app2(H[0], match[0], d)) { var match$1 = Caml_primitive.caml_weak_get(bucket, i); if (match$1) { - _accu = [ - /* :: */0, - match$1[1], + _accu = /* :: */[ + match$1[0], accu ]; _i = i + 1; @@ -467,16 +457,15 @@ function Make(H) { }; }; var stats = function (t) { - var len = t[1].length; - var lens = $$Array.map(length, t[1]); + var len = t[0].length; + var lens = $$Array.map(length, t[0]); $$Array.sort(function (prim, prim$1) { - return Caml_primitive.caml_compare(prim, prim$1); + return Caml_obj.caml_compare(prim, prim$1); }, lens); var totlen = $$Array.fold_left(function (prim, prim$1) { return prim + prim$1; }, 0, lens); - return [ - /* tuple */0, + return /* tuple */[ len, count(t), totlen, @@ -486,7 +475,6 @@ function Make(H) { ]; }; return [ - 0, create, clear, merge, diff --git a/jscomp/test/.depend b/jscomp/test/.depend index b8ca32adf8..d908f63b57 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -5,6 +5,7 @@ array_test.cmi : const_block_test.cmi : inline_edge_cases.cmi : map_test.cmi : +mt.cmi : test_for_map2.cmi : test_inline_map.cmi : test_inline_map2.cmi : @@ -14,21 +15,21 @@ a.cmo : test_order.cmo ../stdlib/string.cmi ../stdlib/set.cmi \ ../stdlib/list.cmi a.cmx : test_order.cmx ../stdlib/string.cmx ../stdlib/set.cmx \ ../stdlib/list.cmx -a_filename_test.cmo : mt.cmo ext_filename.cmo +a_filename_test.cmo : mt.cmi ext_filename.cmo a_filename_test.cmx : mt.cmx ext_filename.cmx -a_list_test.cmo : mt.cmo ext_list.cmo +a_list_test.cmo : mt.cmi ext_list.cmo a_list_test.cmx : mt.cmx ext_list.cmx a_recursive_type.cmo : a_recursive_type.cmi a_recursive_type.cmx : a_recursive_type.cmi a_scope_bug.cmo : a_scope_bug.cmx : -a_string_test.cmo : mt.cmo ../stdlib/list.cmi ext_string.cmo +a_string_test.cmo : mt.cmi ../stdlib/list.cmi ext_string.cmo a_string_test.cmx : mt.cmx ../stdlib/list.cmx ext_string.cmx abstract_type.cmo : abstract_type.cmi abstract_type.cmx : abstract_type.cmi -and_or_tailcall_test.cmo : mt.cmo +and_or_tailcall_test.cmo : mt.cmi and_or_tailcall_test.cmx : mt.cmx -ari_regress_test.cmo : mt.cmo ari_regress_test.cmi +ari_regress_test.cmo : mt.cmi ari_regress_test.cmi ari_regress_test.cmx : mt.cmx ari_regress_test.cmi arith_lexer.cmo : ../stdlib/lexing.cmi arith_syntax.cmo arith_parser.cmo arith_lexer.cmx : ../stdlib/lexing.cmx arith_syntax.cmx arith_parser.cmx @@ -38,7 +39,7 @@ arith_parser.cmx : ../stdlib/parsing.cmx ../stdlib/obj.cmx \ ../stdlib/lexing.cmx arith_syntax.cmx arith_syntax.cmo : arith_syntax.cmx : -array_test.cmo : ../stdlib/pervasives.cmi mt.cmo ../stdlib/list.cmi \ +array_test.cmo : ../stdlib/pervasives.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/array.cmi array_test.cmi array_test.cmx : ../stdlib/pervasives.cmx mt.cmx ../stdlib/list.cmx \ ../stdlib/array.cmx array_test.cmi @@ -46,19 +47,21 @@ b.cmo : b.cmx : bdd.cmo : ../stdlib/array.cmi bdd.cmx : ../stdlib/array.cmx -boolean_test.cmo : test_bool_equal.cmo mt.cmo +boolean_test.cmo : test_bool_equal.cmo mt.cmi boolean_test.cmx : test_bool_equal.cmx mt.cmx -buffer_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi \ +buffer_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/bytes.cmi \ ../stdlib/buffer.cmi buffer_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/bytes.cmx \ ../stdlib/buffer.cmx -complex_if_test.cmo : mt.cmo ../stdlib/bytes.cmi +caml_compare_test.cmo : mt.cmi +caml_compare_test.cmx : mt.cmx +complex_if_test.cmo : mt.cmi ../stdlib/bytes.cmi complex_if_test.cmx : mt.cmx ../stdlib/bytes.cmx -complex_test.cmo : mt.cmo ../stdlib/complex.cmi +complex_test.cmo : mt.cmi ../stdlib/complex.cmi complex_test.cmx : mt.cmx ../stdlib/complex.cmx complex_while_loop.cmo : complex_while_loop.cmx : -const_block_test.cmo : mt.cmo ../stdlib/array.cmi const_block_test.cmi +const_block_test.cmo : mt.cmi ../stdlib/array.cmi const_block_test.cmi const_block_test.cmx : mt.cmx ../stdlib/array.cmx const_block_test.cmi const_defs.cmo : const_defs.cmx : @@ -66,7 +69,7 @@ const_defs_test.cmo : const_defs.cmo const_defs_test.cmx : const_defs.cmx cont_int_fold_test.cmo : cont_int_fold_test.cmx : -cps_test.cmo : mt.cmo ../stdlib/array.cmi +cps_test.cmo : mt.cmi ../stdlib/array.cmi cps_test.cmx : mt.cmx ../stdlib/array.cmx cross_module_inline_test.cmo : cross_module_inline_test.cmx : @@ -76,7 +79,7 @@ demo_page.cmo : demo_page.cmx : empty_obj.cmo : empty_obj.cmx : -equal_exception_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi +equal_exception_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/bytes.cmi equal_exception_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/bytes.cmx equal_test.cmo : equal_test.cmx : @@ -92,67 +95,73 @@ ext_string.cmo : ../stdlib/string.cmi ext_bytes.cmo ../stdlib/bytes.cmi ext_string.cmx : ../stdlib/string.cmx ext_bytes.cmx ../stdlib/bytes.cmx fib.cmo : fib.cmx : -for_loop_test.cmo : mt.cmo ../stdlib/list.cmi ../stdlib/array.cmi +for_loop_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/array.cmi for_loop_test.cmx : mt.cmx ../stdlib/list.cmx ../stdlib/array.cmx -for_side_effect_test.cmo : mt.cmo +for_side_effect_test.cmo : mt.cmi for_side_effect_test.cmx : mt.cmx format_regression.cmo : format_regression.cmx : -genlex_test.cmo : ../stdlib/stream.cmi mt.cmo ../stdlib/list.cmi \ +genlex_test.cmo : ../stdlib/stream.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/genlex.cmi genlex_test.cmx : ../stdlib/stream.cmx mt.cmx ../stdlib/list.cmx \ ../stdlib/genlex.cmx -global_exception_regression_test.cmo : mt.cmo +global_exception_regression_test.cmo : mt.cmi global_exception_regression_test.cmx : mt.cmx -google_closure_test.cmo : test_google_closure.cmo mt.cmo +google_closure_test.cmo : test_google_closure.cmo mt.cmi google_closure_test.cmx : test_google_closure.cmx mt.cmx -hashtbl_test.cmo : mt.cmo ../stdlib/list.cmi ../stdlib/hashtbl.cmi \ +guide_for_ext.cmo : +guide_for_ext.cmx : +hashtbl_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/hashtbl.cmi \ ../stdlib/array.cmi hashtbl_test.cmx : mt.cmx ../stdlib/list.cmx ../stdlib/hashtbl.cmx \ ../stdlib/array.cmx inline_edge_cases.cmo : inline_edge_cases.cmi inline_edge_cases.cmx : inline_edge_cases.cmi -inline_regression_test.cmo : ../stdlib/string.cmi mt.cmo \ +inline_regression_test.cmo : ../stdlib/string.cmi mt.cmi \ ../stdlib/filename.cmi inline_regression_test.cmx : ../stdlib/string.cmx mt.cmx \ ../stdlib/filename.cmx int_map.cmo : ../stdlib/map.cmi int_map.cmx : ../stdlib/map.cmx -lazy_test.cmo : ../stdlib/lazy.cmi -lazy_test.cmx : ../stdlib/lazy.cmx -lexer_test.cmo : number_lexer.cmo mt.cmo ../stdlib/list.cmi \ +lazy_test.cmo : mt.cmi ../stdlib/lazy.cmi +lazy_test.cmx : mt.cmx ../stdlib/lazy.cmx +lexer_test.cmo : number_lexer.cmo mt.cmi ../stdlib/list.cmi \ ../stdlib/lexing.cmi arith_syntax.cmo arith_parser.cmo arith_lexer.cmo lexer_test.cmx : number_lexer.cmx mt.cmx ../stdlib/list.cmx \ ../stdlib/lexing.cmx arith_syntax.cmx arith_parser.cmx arith_lexer.cmx -lib_js_test.cmo : mt.cmo ../lib/js.cmi +lib_js_test.cmo : mt.cmi ../lib/js.cmi lib_js_test.cmx : mt.cmx ../lib/js.cmx -list_test.cmo : ../stdlib/pervasives.cmi mt.cmo ../stdlib/list.cmi \ +list_test.cmo : ../stdlib/pervasives.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/array.cmi list_test.cmx : ../stdlib/pervasives.cmx mt.cmx ../stdlib/list.cmx \ ../stdlib/array.cmx -loop_regression_test.cmo : mt.cmo +local_exception_test.cmo : +local_exception_test.cmx : +loop_regression_test.cmo : mt.cmi loop_regression_test.cmx : mt.cmx -loop_suites_test.cmo : mt.cmo for_loop_test.cmo +loop_suites_test.cmo : mt.cmi for_loop_test.cmo loop_suites_test.cmx : mt.cmx for_loop_test.cmx map_test.cmo : test_map_find.cmo test_inline_map2.cmi test_inline_map.cmi \ - ../stdlib/string.cmi ../stdlib/pervasives.cmi mt.cmo ../stdlib/map.cmi \ + ../stdlib/string.cmi ../stdlib/pervasives.cmi mt.cmi ../stdlib/map.cmi \ ../stdlib/list.cmi map_test.cmi map_test.cmx : test_map_find.cmx test_inline_map2.cmx test_inline_map.cmx \ ../stdlib/string.cmx ../stdlib/pervasives.cmx mt.cmx ../stdlib/map.cmx \ ../stdlib/list.cmx map_test.cmi -module_parameter_test.cmo : ../stdlib/string.cmi mt.cmo +module_parameter_test.cmo : ../stdlib/string.cmi mt.cmi module_parameter_test.cmx : ../stdlib/string.cmx mt.cmx -mt.cmo : ../stdlib/list.cmi -mt.cmx : ../stdlib/list.cmx +mt.cmo : ../stdlib/list.cmi mt.cmi +mt.cmx : ../stdlib/list.cmx mt.cmi number_lexer.cmo : ../stdlib/sys.cmi ../stdlib/lexing.cmi number_lexer.cmx : ../stdlib/sys.cmx ../stdlib/lexing.cmx -obj_test.cmo : mt.cmo +obj_magic_test.cmo : ../stdlib/obj.cmi +obj_magic_test.cmx : ../stdlib/obj.cmx +obj_test.cmo : mt.cmi obj_test.cmx : mt.cmx -of_string_test.cmo : mt.cmo +of_string_test.cmo : mt.cmi of_string_test.cmx : mt.cmx primitive_reg_test.cmo : primitive_reg_test.cmx : -printf_test.cmo : ../stdlib/printf.cmi mt.cmo ../stdlib/format.cmi +printf_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/format.cmi printf_test.cmx : ../stdlib/printf.cmx mt.cmx ../stdlib/format.cmx qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \ ../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \ @@ -160,29 +169,33 @@ qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \ qcc.cmx : ../stdlib/sys.cmx ../stdlib/string.cmx ../stdlib/printf.cmx \ ../stdlib/list.cmx ../stdlib/char.cmx ../stdlib/bytes.cmx \ ../stdlib/array.cmx -queue_test.cmo : ../stdlib/queue.cmi mt.cmo ../stdlib/array.cmi +queue_test.cmo : ../stdlib/queue.cmi mt.cmi ../stdlib/array.cmi queue_test.cmx : ../stdlib/queue.cmx mt.cmx ../stdlib/array.cmx -rec_value_test.cmo : mt.cmo ../stdlib/list.cmi ../stdlib/lazy.cmi +rec_module_test.cmo : ../stdlib/set.cmi ../stdlib/pervasives.cmi mt.cmi +rec_module_test.cmx : ../stdlib/set.cmx ../stdlib/pervasives.cmx mt.cmx +rec_value_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/lazy.cmi rec_value_test.cmx : mt.cmx ../stdlib/list.cmx ../stdlib/lazy.cmx -record_with_test.cmo : mt.cmo +record_with_test.cmo : mt.cmi record_with_test.cmx : mt.cmx regression_print.cmo : regression_print.cmx : -simple_lexer_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/lexing.cmi +runtime_encoding_test.cmo : +runtime_encoding_test.cmx : +simple_lexer_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/lexing.cmi simple_lexer_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/lexing.cmx small_inline_test.cmo : small_inline_test.cmx : -stack_test.cmo : ../stdlib/stack.cmi mt.cmo ../stdlib/list.cmi +stack_test.cmo : ../stdlib/stack.cmi mt.cmi ../stdlib/list.cmi stack_test.cmx : ../stdlib/stack.cmx mt.cmx ../stdlib/list.cmx -statck_test.cmo : ../stdlib/stack.cmi mt.cmo ../stdlib/list.cmi +statck_test.cmo : ../stdlib/stack.cmi mt.cmi ../stdlib/list.cmi statck_test.cmx : ../stdlib/stack.cmx mt.cmx ../stdlib/list.cmx -string_runtime_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/list.cmi \ +string_runtime_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/list.cmi \ ../runtime/caml_string.cmi ../stdlib/bytes.cmi string_runtime_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/list.cmx \ ../runtime/caml_string.cmx ../stdlib/bytes.cmx -string_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi +string_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/bytes.cmi string_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/bytes.cmx -tailcall_inline_test.cmo : mt.cmo ../stdlib/array.cmi +tailcall_inline_test.cmo : mt.cmi ../stdlib/array.cmi tailcall_inline_test.cmx : mt.cmx ../stdlib/array.cmx test.cmo : test.cmx : @@ -258,9 +271,9 @@ test_incomplete.cmo : test_incomplete.cmx : test_incr_ref.cmo : test_incr_ref.cmx : -test_inline_map.cmo : mt.cmo ../stdlib/list.cmi test_inline_map.cmi +test_inline_map.cmo : mt.cmi ../stdlib/list.cmi test_inline_map.cmi test_inline_map.cmx : mt.cmx ../stdlib/list.cmx test_inline_map.cmi -test_inline_map2.cmo : mt.cmo ../stdlib/list.cmi test_inline_map2.cmi +test_inline_map2.cmo : mt.cmi ../stdlib/list.cmi test_inline_map2.cmi test_inline_map2.cmx : mt.cmx ../stdlib/list.cmx test_inline_map2.cmi test_int_map_find.cmo : ../stdlib/map.cmi ../stdlib/list.cmi test_int_map_find.cmx : ../stdlib/map.cmx ../stdlib/list.cmx @@ -280,7 +293,7 @@ test_list.cmo : ../stdlib/list.cmi test_list.cmx : ../stdlib/list.cmx test_literal.cmo : test_literal.cmx : -test_map_find.cmo : mt.cmo ../stdlib/map.cmi ../stdlib/list.cmi +test_map_find.cmo : mt.cmi ../stdlib/map.cmi ../stdlib/list.cmi test_map_find.cmx : mt.cmx ../stdlib/map.cmx ../stdlib/list.cmx test_match_exception.cmo : test_match_exception.cmx : @@ -382,7 +395,7 @@ ticker.cmo : ../stdlib/string.cmi ../stdlib/printf.cmi \ ../stdlib/pervasives.cmi ../stdlib/map.cmi ../stdlib/list.cmi ticker.cmx : ../stdlib/string.cmx ../stdlib/printf.cmx \ ../stdlib/pervasives.cmx ../stdlib/map.cmx ../stdlib/list.cmx -typeof_test.cmo : mt.cmo ../lib/js.cmi +typeof_test.cmo : mt.cmi ../lib/js.cmi typeof_test.cmx : mt.cmx ../lib/js.cmx unitest_string.cmo : unitest_string.cmx : @@ -390,21 +403,21 @@ a.cmo : test_order.cmo ../stdlib/string.cmi ../stdlib/set.cmi \ ../stdlib/list.cmi a.cmj : test_order.cmj ../stdlib/string.cmj ../stdlib/set.cmj \ ../stdlib/list.cmj -a_filename_test.cmo : mt.cmo ext_filename.cmo +a_filename_test.cmo : mt.cmi ext_filename.cmo a_filename_test.cmj : mt.cmj ext_filename.cmj -a_list_test.cmo : mt.cmo ext_list.cmo +a_list_test.cmo : mt.cmi ext_list.cmo a_list_test.cmj : mt.cmj ext_list.cmj a_recursive_type.cmo : a_recursive_type.cmi a_recursive_type.cmj : a_recursive_type.cmi a_scope_bug.cmo : a_scope_bug.cmj : -a_string_test.cmo : mt.cmo ../stdlib/list.cmi ext_string.cmo +a_string_test.cmo : mt.cmi ../stdlib/list.cmi ext_string.cmo a_string_test.cmj : mt.cmj ../stdlib/list.cmj ext_string.cmj abstract_type.cmo : abstract_type.cmi abstract_type.cmj : abstract_type.cmi -and_or_tailcall_test.cmo : mt.cmo +and_or_tailcall_test.cmo : mt.cmi and_or_tailcall_test.cmj : mt.cmj -ari_regress_test.cmo : mt.cmo ari_regress_test.cmi +ari_regress_test.cmo : mt.cmi ari_regress_test.cmi ari_regress_test.cmj : mt.cmj ari_regress_test.cmi arith_lexer.cmo : ../stdlib/lexing.cmi arith_syntax.cmo arith_parser.cmo arith_lexer.cmj : ../stdlib/lexing.cmj arith_syntax.cmj arith_parser.cmj @@ -414,7 +427,7 @@ arith_parser.cmj : ../stdlib/parsing.cmj ../stdlib/obj.cmj \ ../stdlib/lexing.cmj arith_syntax.cmj arith_syntax.cmo : arith_syntax.cmj : -array_test.cmo : ../stdlib/pervasives.cmi mt.cmo ../stdlib/list.cmi \ +array_test.cmo : ../stdlib/pervasives.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/array.cmi array_test.cmi array_test.cmj : ../stdlib/pervasives.cmj mt.cmj ../stdlib/list.cmj \ ../stdlib/array.cmj array_test.cmi @@ -422,19 +435,21 @@ b.cmo : b.cmj : bdd.cmo : ../stdlib/array.cmi bdd.cmj : ../stdlib/array.cmj -boolean_test.cmo : test_bool_equal.cmo mt.cmo +boolean_test.cmo : test_bool_equal.cmo mt.cmi boolean_test.cmj : test_bool_equal.cmj mt.cmj -buffer_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi \ +buffer_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/bytes.cmi \ ../stdlib/buffer.cmi buffer_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/bytes.cmj \ ../stdlib/buffer.cmj -complex_if_test.cmo : mt.cmo ../stdlib/bytes.cmi +caml_compare_test.cmo : mt.cmi +caml_compare_test.cmj : mt.cmj +complex_if_test.cmo : mt.cmi ../stdlib/bytes.cmi complex_if_test.cmj : mt.cmj ../stdlib/bytes.cmj -complex_test.cmo : mt.cmo ../stdlib/complex.cmi +complex_test.cmo : mt.cmi ../stdlib/complex.cmi complex_test.cmj : mt.cmj ../stdlib/complex.cmj complex_while_loop.cmo : complex_while_loop.cmj : -const_block_test.cmo : mt.cmo ../stdlib/array.cmi const_block_test.cmi +const_block_test.cmo : mt.cmi ../stdlib/array.cmi const_block_test.cmi const_block_test.cmj : mt.cmj ../stdlib/array.cmj const_block_test.cmi const_defs.cmo : const_defs.cmj : @@ -442,7 +457,7 @@ const_defs_test.cmo : const_defs.cmo const_defs_test.cmj : const_defs.cmj cont_int_fold_test.cmo : cont_int_fold_test.cmj : -cps_test.cmo : mt.cmo ../stdlib/array.cmi +cps_test.cmo : mt.cmi ../stdlib/array.cmi cps_test.cmj : mt.cmj ../stdlib/array.cmj cross_module_inline_test.cmo : cross_module_inline_test.cmj : @@ -452,7 +467,7 @@ demo_page.cmo : demo_page.cmj : empty_obj.cmo : empty_obj.cmj : -equal_exception_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi +equal_exception_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/bytes.cmi equal_exception_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/bytes.cmj equal_test.cmo : equal_test.cmj : @@ -468,67 +483,73 @@ ext_string.cmo : ../stdlib/string.cmi ext_bytes.cmo ../stdlib/bytes.cmi ext_string.cmj : ../stdlib/string.cmj ext_bytes.cmj ../stdlib/bytes.cmj fib.cmo : fib.cmj : -for_loop_test.cmo : mt.cmo ../stdlib/list.cmi ../stdlib/array.cmi +for_loop_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/array.cmi for_loop_test.cmj : mt.cmj ../stdlib/list.cmj ../stdlib/array.cmj -for_side_effect_test.cmo : mt.cmo +for_side_effect_test.cmo : mt.cmi for_side_effect_test.cmj : mt.cmj format_regression.cmo : format_regression.cmj : -genlex_test.cmo : ../stdlib/stream.cmi mt.cmo ../stdlib/list.cmi \ +genlex_test.cmo : ../stdlib/stream.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/genlex.cmi genlex_test.cmj : ../stdlib/stream.cmj mt.cmj ../stdlib/list.cmj \ ../stdlib/genlex.cmj -global_exception_regression_test.cmo : mt.cmo +global_exception_regression_test.cmo : mt.cmi global_exception_regression_test.cmj : mt.cmj -google_closure_test.cmo : test_google_closure.cmo mt.cmo +google_closure_test.cmo : test_google_closure.cmo mt.cmi google_closure_test.cmj : test_google_closure.cmj mt.cmj -hashtbl_test.cmo : mt.cmo ../stdlib/list.cmi ../stdlib/hashtbl.cmi \ +guide_for_ext.cmo : +guide_for_ext.cmj : +hashtbl_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/hashtbl.cmi \ ../stdlib/array.cmi hashtbl_test.cmj : mt.cmj ../stdlib/list.cmj ../stdlib/hashtbl.cmj \ ../stdlib/array.cmj inline_edge_cases.cmo : inline_edge_cases.cmi inline_edge_cases.cmj : inline_edge_cases.cmi -inline_regression_test.cmo : ../stdlib/string.cmi mt.cmo \ +inline_regression_test.cmo : ../stdlib/string.cmi mt.cmi \ ../stdlib/filename.cmi inline_regression_test.cmj : ../stdlib/string.cmj mt.cmj \ ../stdlib/filename.cmj int_map.cmo : ../stdlib/map.cmi int_map.cmj : ../stdlib/map.cmj -lazy_test.cmo : ../stdlib/lazy.cmi -lazy_test.cmj : ../stdlib/lazy.cmj -lexer_test.cmo : number_lexer.cmo mt.cmo ../stdlib/list.cmi \ +lazy_test.cmo : mt.cmi ../stdlib/lazy.cmi +lazy_test.cmj : mt.cmj ../stdlib/lazy.cmj +lexer_test.cmo : number_lexer.cmo mt.cmi ../stdlib/list.cmi \ ../stdlib/lexing.cmi arith_syntax.cmo arith_parser.cmo arith_lexer.cmo lexer_test.cmj : number_lexer.cmj mt.cmj ../stdlib/list.cmj \ ../stdlib/lexing.cmj arith_syntax.cmj arith_parser.cmj arith_lexer.cmj -lib_js_test.cmo : mt.cmo ../lib/js.cmi +lib_js_test.cmo : mt.cmi ../lib/js.cmi lib_js_test.cmj : mt.cmj ../lib/js.cmj -list_test.cmo : ../stdlib/pervasives.cmi mt.cmo ../stdlib/list.cmi \ +list_test.cmo : ../stdlib/pervasives.cmi mt.cmi ../stdlib/list.cmi \ ../stdlib/array.cmi list_test.cmj : ../stdlib/pervasives.cmj mt.cmj ../stdlib/list.cmj \ ../stdlib/array.cmj -loop_regression_test.cmo : mt.cmo +local_exception_test.cmo : +local_exception_test.cmj : +loop_regression_test.cmo : mt.cmi loop_regression_test.cmj : mt.cmj -loop_suites_test.cmo : mt.cmo for_loop_test.cmo +loop_suites_test.cmo : mt.cmi for_loop_test.cmo loop_suites_test.cmj : mt.cmj for_loop_test.cmj map_test.cmo : test_map_find.cmo test_inline_map2.cmi test_inline_map.cmi \ - ../stdlib/string.cmi ../stdlib/pervasives.cmi mt.cmo ../stdlib/map.cmi \ + ../stdlib/string.cmi ../stdlib/pervasives.cmi mt.cmi ../stdlib/map.cmi \ ../stdlib/list.cmi map_test.cmi map_test.cmj : test_map_find.cmj test_inline_map2.cmj test_inline_map.cmj \ ../stdlib/string.cmj ../stdlib/pervasives.cmj mt.cmj ../stdlib/map.cmj \ ../stdlib/list.cmj map_test.cmi -module_parameter_test.cmo : ../stdlib/string.cmi mt.cmo +module_parameter_test.cmo : ../stdlib/string.cmi mt.cmi module_parameter_test.cmj : ../stdlib/string.cmj mt.cmj -mt.cmo : ../stdlib/list.cmi -mt.cmj : ../stdlib/list.cmj +mt.cmo : ../stdlib/list.cmi mt.cmi +mt.cmj : ../stdlib/list.cmj mt.cmi number_lexer.cmo : ../stdlib/sys.cmi ../stdlib/lexing.cmi number_lexer.cmj : ../stdlib/sys.cmj ../stdlib/lexing.cmj -obj_test.cmo : mt.cmo +obj_magic_test.cmo : ../stdlib/obj.cmi +obj_magic_test.cmj : ../stdlib/obj.cmj +obj_test.cmo : mt.cmi obj_test.cmj : mt.cmj -of_string_test.cmo : mt.cmo +of_string_test.cmo : mt.cmi of_string_test.cmj : mt.cmj primitive_reg_test.cmo : primitive_reg_test.cmj : -printf_test.cmo : ../stdlib/printf.cmi mt.cmo ../stdlib/format.cmi +printf_test.cmo : ../stdlib/printf.cmi mt.cmi ../stdlib/format.cmi printf_test.cmj : ../stdlib/printf.cmj mt.cmj ../stdlib/format.cmj qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \ ../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \ @@ -536,29 +557,33 @@ qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \ qcc.cmj : ../stdlib/sys.cmj ../stdlib/string.cmj ../stdlib/printf.cmj \ ../stdlib/list.cmj ../stdlib/char.cmj ../stdlib/bytes.cmj \ ../stdlib/array.cmj -queue_test.cmo : ../stdlib/queue.cmi mt.cmo ../stdlib/array.cmi +queue_test.cmo : ../stdlib/queue.cmi mt.cmi ../stdlib/array.cmi queue_test.cmj : ../stdlib/queue.cmj mt.cmj ../stdlib/array.cmj -rec_value_test.cmo : mt.cmo ../stdlib/list.cmi ../stdlib/lazy.cmi +rec_module_test.cmo : ../stdlib/set.cmi ../stdlib/pervasives.cmi mt.cmi +rec_module_test.cmj : ../stdlib/set.cmj ../stdlib/pervasives.cmj mt.cmj +rec_value_test.cmo : mt.cmi ../stdlib/list.cmi ../stdlib/lazy.cmi rec_value_test.cmj : mt.cmj ../stdlib/list.cmj ../stdlib/lazy.cmj -record_with_test.cmo : mt.cmo +record_with_test.cmo : mt.cmi record_with_test.cmj : mt.cmj regression_print.cmo : regression_print.cmj : -simple_lexer_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/lexing.cmi +runtime_encoding_test.cmo : +runtime_encoding_test.cmj : +simple_lexer_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/lexing.cmi simple_lexer_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/lexing.cmj small_inline_test.cmo : small_inline_test.cmj : -stack_test.cmo : ../stdlib/stack.cmi mt.cmo ../stdlib/list.cmi +stack_test.cmo : ../stdlib/stack.cmi mt.cmi ../stdlib/list.cmi stack_test.cmj : ../stdlib/stack.cmj mt.cmj ../stdlib/list.cmj -statck_test.cmo : ../stdlib/stack.cmi mt.cmo ../stdlib/list.cmi +statck_test.cmo : ../stdlib/stack.cmi mt.cmi ../stdlib/list.cmi statck_test.cmj : ../stdlib/stack.cmj mt.cmj ../stdlib/list.cmj -string_runtime_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/list.cmi \ +string_runtime_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/list.cmi \ ../runtime/caml_string.cmi ../stdlib/bytes.cmi string_runtime_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/list.cmj \ ../runtime/caml_string.cmj ../stdlib/bytes.cmj -string_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi +string_test.cmo : ../stdlib/string.cmi mt.cmi ../stdlib/bytes.cmi string_test.cmj : ../stdlib/string.cmj mt.cmj ../stdlib/bytes.cmj -tailcall_inline_test.cmo : mt.cmo ../stdlib/array.cmi +tailcall_inline_test.cmo : mt.cmi ../stdlib/array.cmi tailcall_inline_test.cmj : mt.cmj ../stdlib/array.cmj test.cmo : test.cmj : @@ -634,9 +659,9 @@ test_incomplete.cmo : test_incomplete.cmj : test_incr_ref.cmo : test_incr_ref.cmj : -test_inline_map.cmo : mt.cmo ../stdlib/list.cmi test_inline_map.cmi +test_inline_map.cmo : mt.cmi ../stdlib/list.cmi test_inline_map.cmi test_inline_map.cmj : mt.cmj ../stdlib/list.cmj test_inline_map.cmi -test_inline_map2.cmo : mt.cmo ../stdlib/list.cmi test_inline_map2.cmi +test_inline_map2.cmo : mt.cmi ../stdlib/list.cmi test_inline_map2.cmi test_inline_map2.cmj : mt.cmj ../stdlib/list.cmj test_inline_map2.cmi test_int_map_find.cmo : ../stdlib/map.cmi ../stdlib/list.cmi test_int_map_find.cmj : ../stdlib/map.cmj ../stdlib/list.cmj @@ -656,7 +681,7 @@ test_list.cmo : ../stdlib/list.cmi test_list.cmj : ../stdlib/list.cmj test_literal.cmo : test_literal.cmj : -test_map_find.cmo : mt.cmo ../stdlib/map.cmi ../stdlib/list.cmi +test_map_find.cmo : mt.cmi ../stdlib/map.cmi ../stdlib/list.cmi test_map_find.cmj : mt.cmj ../stdlib/map.cmj ../stdlib/list.cmj test_match_exception.cmo : test_match_exception.cmj : @@ -758,7 +783,7 @@ ticker.cmo : ../stdlib/string.cmi ../stdlib/printf.cmi \ ../stdlib/pervasives.cmi ../stdlib/map.cmi ../stdlib/list.cmi ticker.cmj : ../stdlib/string.cmj ../stdlib/printf.cmj \ ../stdlib/pervasives.cmj ../stdlib/map.cmj ../stdlib/list.cmj -typeof_test.cmo : mt.cmo ../lib/js.cmi +typeof_test.cmo : mt.cmi ../lib/js.cmi typeof_test.cmj : mt.cmj ../lib/js.cmj unitest_string.cmo : unitest_string.cmj : diff --git a/jscomp/test/a_filename_test.js b/jscomp/test/a_filename_test.js index a9c392354d..e70bad8a77 100644 --- a/jscomp/test/a_filename_test.js +++ b/jscomp/test/a_filename_test.js @@ -5,8 +5,7 @@ var Mt = require("./mt"); var Assert = require("assert"); var Ext_filename = require("./ext_filename"); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "basic", function () { var prim = Ext_filename.node_relative_path("./a/b.c", "./a/u/g.c"); @@ -14,9 +13,8 @@ var suites_001 = [ } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/a_list_test.js b/jscomp/test/a_list_test.js index 35aa6ac02d..6b5c0e7946 100644 --- a/jscomp/test/a_list_test.js +++ b/jscomp/test/a_list_test.js @@ -4,81 +4,65 @@ var Mt = require("./mt"); var Ext_list = require("./ext_list"); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "drop", function () { - return [ - /* Eq */0, - Ext_list.drop(3, [ - /* :: */0, + return /* Eq */{ + 0: Ext_list.drop(3, /* :: */[ 0, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, /* [] */0 ] ] ]), - /* [] */0 - ]; + 1: /* [] */0, + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "drop1", function () { - return [ - /* Eq */0, - Ext_list.drop(2, [ - /* :: */0, + return /* Eq */{ + 0: Ext_list.drop(2, /* :: */[ 0, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, /* [] */0 ] ] ]), - [ - /* :: */0, + 1: /* :: */[ 2, /* [] */0 - ] - ]; + ], + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "flat_map", function () { - return [ - /* Eq */0, - [ - /* :: */0, + return /* Eq */{ + 0: /* :: */[ 0, - [ - /* :: */0, + /* :: */[ 0, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 0, /* [] */0 ] @@ -86,53 +70,47 @@ var suites_002 = [ ] ] ], - Ext_list.flat_map(function (x) { + 1: Ext_list.flat_map(function (x) { if (x % 2) { - return [ - /* :: */0, + return /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ 0, /* [] */0 ]; } - }, [ - /* :: */0, + }, /* :: */[ 0, - [ - /* :: */0, + /* :: */[ 0, - [ - /* :: */0, + /* :: */[ 3, - [ - /* :: */0, + /* :: */[ 0, /* [] */0 ] ] ] - ]) - ]; + ]), + length: 2, + tag: 0 + }; } ], /* [] */0 ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("a_list_test.ml", suites); diff --git a/jscomp/test/a_recursive_type.js b/jscomp/test/a_recursive_type.js index 3939a85f45..0773acd86c 100644 --- a/jscomp/test/a_recursive_type.js +++ b/jscomp/test/a_recursive_type.js @@ -4,18 +4,20 @@ var Caml_curry = require("../runtime/caml_curry"); function g(x) { - return Caml_curry.app1(x[1], x); + return Caml_curry.app1(x[0], x); } -var loop = g([ - /* A */0, - g - ]); +var loop = g(/* A */{ + 0: g, + length: 1, + tag: 0 + }); -var x = [ - /* A */0, - g -]; +var x = /* A */{ + 0: g, + length: 1, + tag: 0 +}; var non_terminate = g(x); diff --git a/jscomp/test/a_string_test.js b/jscomp/test/a_string_test.js index 8dacfb598b..f62247ce6b 100644 --- a/jscomp/test/a_string_test.js +++ b/jscomp/test/a_string_test.js @@ -10,22 +10,15 @@ var split = Ext_string.split; var split_by = Ext_string.split_by; -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "split", function () { - var prim = split([ - /* Some */0, - /* true */1 - ], "hihi", /* "i" */105); - return Assert.deepEqual(prim, [ - /* :: */0, + var prim = split(/* Some */[/* true */1], "hihi", /* "i" */105); + return Assert.deepEqual(prim, /* :: */[ "h", - [ - /* :: */0, + /* :: */[ "h", - [ - /* :: */0, + /* :: */[ "", /* [] */0 ] @@ -34,59 +27,41 @@ var suites_001 = [ } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "split_non_empty", function () { var prim = split(/* None */0, "hihi", /* "i" */105); - return Assert.deepEqual(prim, [ - /* :: */0, + return Assert.deepEqual(prim, /* :: */[ "h", - [ - /* :: */0, + /* :: */[ "h", /* [] */0 ] ]); } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "splitempty", function () { - var prim = split([ - /* Some */0, - /* true */1 - ], "", /* "i" */105); - return Assert.deepEqual(prim, [ - /* :: */0, + var prim = split(/* Some */[/* true */1], "", /* "i" */105); + return Assert.deepEqual(prim, /* :: */[ "", /* [] */0 ]); } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "split_normal", function () { - var prim = split([ - /* Some */0, - /* true */1 - ], "h i i", /* " " */32); - return Assert.deepEqual(prim, [ - /* :: */0, + var prim = split(/* Some */[/* true */1], "h i i", /* " " */32); + return Assert.deepEqual(prim, /* :: */[ "h", - [ - /* :: */0, + /* :: */[ "i", - [ - /* :: */0, + /* :: */[ "i", /* [] */0 ] @@ -94,10 +69,8 @@ var suites_002 = [ ]); } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "split_by", function () { var prim = List.filter(function (s) { @@ -110,17 +83,13 @@ var suites_002 = [ return +(x === /* "\t" */9); } }, "h hgso hgso \t hi")); - return Assert.deepEqual(prim, [ - /* :: */0, + return Assert.deepEqual(prim, /* :: */[ "h", - [ - /* :: */0, + /* :: */[ "hgso", - [ - /* :: */0, + /* :: */[ "hgso", - [ - /* :: */0, + /* :: */[ "hi", /* [] */0 ] @@ -135,10 +104,9 @@ var suites_002 = [ ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_suites("a_string_test.ml", suites); diff --git a/jscomp/test/and_or_tailcall_test.js b/jscomp/test/and_or_tailcall_test.js index c41a2f842f..3de4d54b84 100644 --- a/jscomp/test/and_or_tailcall_test.js +++ b/jscomp/test/and_or_tailcall_test.js @@ -37,38 +37,36 @@ function or_f(b, _, _n) { }; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "and_tail", function () { - return [ - /* Eq */0, - /* false */0, - f(/* true */1, 1, 0) - ]; + return /* Eq */{ + 0: /* false */0, + 1: f(/* true */1, 1, 0), + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "or_tail", function () { - return [ - /* Eq */0, - /* false */0, - or_f(/* false */0, 1, 0) - ]; + return /* Eq */{ + 0: /* false */0, + 1: or_f(/* false */0, 1, 0), + length: 2, + tag: 0 + }; } ], /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("and_or_tailcall_test.ml", suites); diff --git a/jscomp/test/ari_regress_test.js b/jscomp/test/ari_regress_test.js index dc4bceb884..b496be3807 100644 --- a/jscomp/test/ari_regress_test.js +++ b/jscomp/test/ari_regress_test.js @@ -26,52 +26,49 @@ function v(param) { return g1(3, 4)(6, param); } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "curry", function () { - return [ - /* Eq */0, - g, - 7 - ]; + return /* Eq */{ + 0: g, + 1: 7, + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "curry2", function () { - return [ - /* Eq */0, - 14, - Caml_curry.app1(v, 1) - ]; + return /* Eq */{ + 0: 14, + 1: Caml_curry.app1(v, 1), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "curry3", function () { - return [ - /* Eq */0, - x, - 14 - ]; + return /* Eq */{ + 0: x, + 1: 14, + length: 2, + tag: 0 + }; } ], /* [] */0 ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("ari_regress_test.ml", suites); diff --git a/jscomp/test/arith_lexer.js b/jscomp/test/arith_lexer.js index 2ef59b31c8..aa9a3b7954 100644 --- a/jscomp/test/arith_lexer.js +++ b/jscomp/test/arith_lexer.js @@ -6,8 +6,7 @@ var Caml_format = require("../runtime/caml_format"); var Lexing = require("../stdlib/lexing"); var Caml_curry = require("../runtime/caml_curry"); -var __ocaml_lex_tables = [ - /* record */0, +var __ocaml_lex_tables = /* record */[ "\0\0\xf6\xff\xf7\xff\xf8\xff\xf9\xff\xfa\xff\xfb\xff\xfc\xff:\0\x85\0\xff\xff", "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x02\0\x01\0\xff\xff", "\xff\xff\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\xff\xff\xff\0\0", @@ -30,7 +29,7 @@ function __ocaml_lex_lexeme_rec(lexbuf, ___ocaml_lex_state) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); if (__ocaml_lex_state$1 > 9 || __ocaml_lex_state$1 < 0) { - Caml_curry.app1(lexbuf[1], lexbuf); + Caml_curry.app1(lexbuf[0], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; continue ; @@ -41,15 +40,17 @@ function __ocaml_lex_lexeme_rec(lexbuf, ___ocaml_lex_state) { ___ocaml_lex_state = 0; continue ; case 1 : - return [ - /* NUMERAL */0, - Caml_format.caml_int_of_string(Lexing.lexeme(lexbuf)) - ]; + return /* NUMERAL */{ + 0: Caml_format.caml_int_of_string(Lexing.lexeme(lexbuf)), + length: 1, + tag: 0 + }; case 2 : - return [ - /* IDENT */1, - Lexing.lexeme(lexbuf) - ]; + return /* IDENT */{ + 0: Lexing.lexeme(lexbuf), + length: 1, + tag: 1 + }; case 3 : return /* PLUS */0; case 4 : @@ -71,21 +72,21 @@ function __ocaml_lex_lexeme_rec(lexbuf, ___ocaml_lex_state) { } function str(e) { - switch (e[0]) { + switch (e.tag | 0) { case 0 : - return Pervasives.string_of_float(e[1]); + return Pervasives.string_of_float(e[0]); case 1 : - return str(e[1]) + ("+" + str(e[2])); + return str(e[0]) + ("+" + str(e[1])); case 2 : - return str(e[1]) + ("-" + str(e[2])); + return str(e[0]) + ("-" + str(e[1])); case 3 : - return str(e[1]) + ("*" + str(e[2])); + return str(e[0]) + ("*" + str(e[1])); case 4 : - return str(e[1]) + ("/" + str(e[2])); + return str(e[0]) + ("/" + str(e[1])); case 5 : - return "-" + str(e[1]); + return "-" + str(e[0]); case 6 : - return e[1]; + return e[0]; } } diff --git a/jscomp/test/arith_parser.js b/jscomp/test/arith_parser.js index 856ed6543b..229ce8e0fe 100644 --- a/jscomp/test/arith_parser.js +++ b/jscomp/test/arith_parser.js @@ -16,7 +16,7 @@ var yytransl_const = /* array */[ 0 ]; -var yytransl_block = /* array */[ +var yytransl_block = /* int array */[ 257, 258, 0 @@ -49,7 +49,6 @@ var yynames_block = "NUMERAL\0IDENT\0"; var yyact = /* array */[ function () { throw [ - 0, Caml_builtin_exceptions.Failure, "parser" ]; @@ -59,75 +58,80 @@ var yyact = /* array */[ }, function (__caml_parser_env) { var _1 = Parsing.peek_val(__caml_parser_env, 0); - return [ - /* Numeral */0, - _1 - ]; + return /* Numeral */{ + 0: _1, + length: 1, + tag: 0 + }; }, function (__caml_parser_env) { var _1 = Parsing.peek_val(__caml_parser_env, 0); - return [ - /* Variable */6, - _1 - ]; + return /* Variable */{ + 0: _1, + length: 1, + tag: 6 + }; }, function (__caml_parser_env) { var _1 = Parsing.peek_val(__caml_parser_env, 2); var _3 = Parsing.peek_val(__caml_parser_env, 0); - return [ - /* Plus */1, - _1, - _3 - ]; + return /* Plus */{ + 0: _1, + 1: _3, + length: 2, + tag: 1 + }; }, function (__caml_parser_env) { var _1 = Parsing.peek_val(__caml_parser_env, 2); var _3 = Parsing.peek_val(__caml_parser_env, 0); - return [ - /* Minus */2, - _1, - _3 - ]; + return /* Minus */{ + 0: _1, + 1: _3, + length: 2, + tag: 2 + }; }, function (__caml_parser_env) { var _1 = Parsing.peek_val(__caml_parser_env, 2); var _3 = Parsing.peek_val(__caml_parser_env, 0); - return [ - /* Times */3, - _1, - _3 - ]; + return /* Times */{ + 0: _1, + 1: _3, + length: 2, + tag: 3 + }; }, function (__caml_parser_env) { var _1 = Parsing.peek_val(__caml_parser_env, 2); var _3 = Parsing.peek_val(__caml_parser_env, 0); - return [ - /* Divide */4, - _1, - _3 - ]; + return /* Divide */{ + 0: _1, + 1: _3, + length: 2, + tag: 4 + }; }, function (__caml_parser_env) { var _2 = Parsing.peek_val(__caml_parser_env, 0); - return [ - /* Negate */5, - _2 - ]; + return /* Negate */{ + 0: _2, + length: 1, + tag: 5 + }; }, function (__caml_parser_env) { return Parsing.peek_val(__caml_parser_env, 1); }, function (__caml_parser_env) { throw [ - 0, Parsing.YYexit, Parsing.peek_val(__caml_parser_env, 0) ]; } ]; -var yytables = [ - /* record */0, +var yytables = /* record */[ yyact, yytransl_const, yytransl_block, diff --git a/jscomp/test/arith_syntax.js b/jscomp/test/arith_syntax.js index 5c7739aa4b..bd33b61da7 100644 --- a/jscomp/test/arith_syntax.js +++ b/jscomp/test/arith_syntax.js @@ -4,21 +4,21 @@ var Pervasives = require("../stdlib/pervasives"); function str(e) { - switch (e[0]) { + switch (e.tag | 0) { case 0 : - return Pervasives.string_of_float(e[1]); + return Pervasives.string_of_float(e[0]); case 1 : - return str(e[1]) + ("+" + str(e[2])); + return str(e[0]) + ("+" + str(e[1])); case 2 : - return str(e[1]) + ("-" + str(e[2])); + return str(e[0]) + ("-" + str(e[1])); case 3 : - return str(e[1]) + ("*" + str(e[2])); + return str(e[0]) + ("*" + str(e[1])); case 4 : - return str(e[1]) + ("/" + str(e[2])); + return str(e[0]) + ("/" + str(e[1])); case 5 : - return "-" + str(e[1]); + return "-" + str(e[0]); case 6 : - return e[1]; + return e[0]; } } diff --git a/jscomp/test/array_test.js b/jscomp/test/array_test.js index e6691f853f..c8e466ff45 100644 --- a/jscomp/test/array_test.js +++ b/jscomp/test/array_test.js @@ -1,11 +1,11 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Mt = require("./mt"); -var Caml_primitive = require("../runtime/caml_primitive"); -var Caml_array = require("../runtime/caml_array"); -var $$Array = require("../stdlib/array"); -var List = require("../stdlib/list"); +var Caml_obj = require("../runtime/caml_obj"); +var Mt = require("./mt"); +var Caml_array = require("../runtime/caml_array"); +var $$Array = require("../stdlib/array"); +var List = require("../stdlib/list"); function is_sorted(x) { var len = x.length; @@ -15,7 +15,7 @@ function is_sorted(x) { if (i >= len - 1) { return /* true */1; } - else if (Caml_primitive.caml_lessthan(x[i], x[i + 1])) { + else if (Caml_obj.caml_lessthan(x[i], x[i + 1])) { _i = i + 1; continue ; @@ -26,70 +26,62 @@ function is_sorted(x) { }; } -var array_suites_001 = [ - /* tuple */0, +var array_suites_000 = /* tuple */[ "init", function () { - return [ - /* Eq */0, - $$Array.init(5, function (x) { + return /* Eq */{ + 0: $$Array.init(5, function (x) { return x; }), - /* array */[ + 1: /* array */[ 0, 1, 2, 3, 4 - ] - ]; + ], + length: 2, + tag: 0 + }; } ]; -var array_suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var array_suites_001 = /* :: */[ + /* tuple */[ "toList", function () { var aux = function (xs) { return List.fold_left(function (acc, param) { - return [ - /* :: */0, - [ - /* tuple */0, - $$Array.to_list(param[1]), - param[2] + return /* :: */[ + /* tuple */[ + $$Array.to_list(param[0]), + param[1] ], acc ]; }, /* [] */0, xs); }; - var match = List.split(aux([ - /* :: */0, - [ - /* tuple */0, - /* array */[], + var match = List.split(aux(/* :: */[ + /* tuple */[ + /* int array */[], /* [] */0 ], /* [] */0 ])); - return [ - /* Eq */0, - match[1], - match[2] - ]; + return /* Eq */{ + 0: match[0], + 1: match[1], + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "concat", function () { - return [ - /* Eq */0, - /* array */[ + return /* Eq */{ + 0: /* array */[ 0, 1, 2, @@ -97,77 +89,71 @@ var array_suites_002 = [ 4, 5 ], - Caml_array.caml_array_concat([ - /* :: */0, - /* array */[ + 1: Caml_array.caml_array_concat(/* :: */[ + /* int array */[ 0, 1, 2 ], - [ - /* :: */0, - /* array */[ + /* :: */[ + /* int array */[ 3, 4 ], - [ - /* :: */0, - /* array */[], - [ - /* :: */0, - /* array */[5], + /* :: */[ + /* int array */[], + /* :: */[ + /* int array */[5], /* [] */0 ] ] ] - ]) - ]; + ]), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "make", function () { - return [ - /* Eq */0, - Caml_array.caml_make_vect(100, /* "a" */97), - $$Array.init(100, function () { + return /* Eq */{ + 0: Caml_array.caml_make_vect(100, /* "a" */97), + 1: $$Array.init(100, function () { return /* "a" */97; - }) - ]; + }), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "sub", function () { - return [ - /* Eq */0, - $$Array.sub(/* array */[ + return /* Eq */{ + 0: $$Array.sub(/* array */[ 0, 1, 2, 3, 4 ], 2, 2), - /* array */[ + 1: /* int array */[ 2, 3 - ] - ]; + ], + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "blit", function () { - var u = /* array */[ + var u = /* int array */[ 100, 0, 0 @@ -176,87 +162,83 @@ var array_suites_002 = [ return x * 2; }); $$Array.blit(v, 1, u, 1, 2); - return [ - /* Eq */0, - [ - /* tuple */0, - /* array */[ + return /* Eq */{ + 0: /* tuple */[ + /* int array */[ 0, 2, 4 ], - /* array */[ + /* int array */[ 100, 2, 4 ] ], - [ - /* tuple */0, + 1: /* tuple */[ v, u - ] - ]; + ], + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "make", function () { - return [ - /* Eq */0, - Caml_array.caml_make_vect(2, 1), - /* array */[ + return /* Eq */{ + 0: Caml_array.caml_make_vect(2, 1), + 1: /* int array */[ 1, 1 - ] - ]; + ], + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "sort", function () { - var u = /* array */[ + var u = /* int array */[ 3, 0, 1 ]; $$Array.sort(function (x, y) { - return Caml_primitive.caml_int_compare(x, y); + return Caml_obj.caml_int_compare(x, y); }, u); - return [ - /* Eq */0, - Caml_primitive.caml_equal(/* array */[ + return /* Eq */{ + 0: Caml_obj.caml_equal(/* int array */[ 0, 1, 3 ], u), - /* true */1 - ]; + 1: /* true */1, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "sort_large", function () { var v = $$Array.init(4, function (i) { return i % 17; }); $$Array.sort(function (x, y) { - return Caml_primitive.caml_int_compare(x, y); + return Caml_obj.caml_int_compare(x, y); }, v); - return [ - /* Eq */0, - /* true */1, - is_sorted(v) - ]; + return /* Eq */{ + 0: /* true */1, + 1: is_sorted(v), + length: 2, + tag: 0 + }; } ], /* [] */0 @@ -269,12 +251,14 @@ var array_suites_002 = [ ] ]; -var array_suites = [ - /* :: */0, - array_suites_001, - array_suites_002 +var array_suites = /* :: */[ + array_suites_000, + array_suites_001 ]; -Mt.from_pair_suites("array_test.ml", array_suites); +Mt.from_pair_suites("array_test.ml", [ + is_sorted, + array_suites + ][1]); /* Not a pure module */ diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index f79665de6e..7bd9db5bec 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -15,13 +15,13 @@ function $$eval(_bdd, vars) { return /* true */1; } } - else if (vars[bdd[2]]) { - _bdd = bdd[4]; + else if (vars[bdd[1]]) { + _bdd = bdd[3]; continue ; } else { - _bdd = bdd[1]; + _bdd = bdd[0]; continue ; } @@ -38,51 +38,37 @@ function getId(bdd) { } } else { - return bdd[3]; + return bdd[2]; } } var initSize_1 = 8 * 1024 - 1; -var nodeC = [ - 0, - 1 -]; +var nodeC = [1]; -var sz_1 = [ - 0, - initSize_1 -]; +var sz_1 = [initSize_1]; -var htab = [ - 0, - Caml_array.caml_make_vect(sz_1[1] + 1, /* [] */0) -]; +var htab = [Caml_array.caml_make_vect(sz_1[0] + 1, /* [] */0)]; -var n_items = [ - 0, - 0 -]; +var n_items = [0]; function hashVal(x, y, v) { return (x << 1) + y + (v << 2); } function resize(newSize) { - var arr = htab[1]; + var arr = htab[0]; var newSz_1 = newSize - 1; var newArr = Caml_array.caml_make_vect(newSize, /* [] */0); var copyBucket = function (_bucket) { while(true) { var bucket = _bucket; if (bucket) { - var n = bucket[1]; + var n = bucket[0]; if (typeof n === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "bdd.ml", 54, 27 @@ -90,13 +76,12 @@ function resize(newSize) { ]; } else { - var ind = hashVal(getId(n[1]), getId(n[4]), n[2]) & newSz_1; - newArr[ind] = [ - /* :: */0, + var ind = hashVal(getId(n[0]), getId(n[3]), n[1]) & newSz_1; + newArr[ind] = /* :: */[ n, newArr[ind] ]; - _bucket = bucket[2]; + _bucket = bucket[1]; continue ; } @@ -106,40 +91,38 @@ function resize(newSize) { } }; }; - for(var n = 0 ,n_finish = sz_1[1]; n<= n_finish; ++n){ + for(var n = 0 ,n_finish = sz_1[0]; n<= n_finish; ++n){ copyBucket(arr[n]); } - htab[1] = newArr; - sz_1[1] = newSz_1; + htab[0] = newArr; + sz_1[0] = newSz_1; return /* () */0; } function insert(idl, idh, v, ind, bucket, newNode) { - if (n_items[1] <= sz_1[1]) { - htab[1][ind] = [ - /* :: */0, + if (n_items[0] <= sz_1[0]) { + htab[0][ind] = /* :: */[ newNode, bucket ]; - return ++ n_items[1]; + return ++ n_items[0]; } else { - resize(sz_1[1] + sz_1[1] + 2); - var ind$1 = hashVal(idl, idh, v) & sz_1[1]; - htab[1][ind$1] = [ - /* :: */0, + resize(sz_1[0] + sz_1[0] + 2); + var ind$1 = hashVal(idl, idh, v) & sz_1[0]; + htab[0][ind$1] = /* :: */[ newNode, - htab[1][ind$1] + htab[0][ind$1] ]; return /* () */0; } } function resetUnique() { - sz_1[1] = initSize_1; - htab[1] = Caml_array.caml_make_vect(sz_1[1] + 1, /* [] */0); - n_items[1] = 0; - nodeC[1] = 1; + sz_1[0] = initSize_1; + htab[0] = Caml_array.caml_make_vect(sz_1[0] + 1, /* [] */0); + n_items[0] = 0; + nodeC[0] = 1; return /* () */0; } @@ -150,43 +133,42 @@ function mkNode(low, v, high) { return low; } else { - var ind = hashVal(idl, idh, v) & sz_1[1]; - var bucket = htab[1][ind]; + var ind = hashVal(idl, idh, v) & sz_1[0]; + var bucket = htab[0][ind]; var _b = bucket; while(true) { var b = _b; if (b) { - var n = b[1]; + var n = b[0]; if (typeof n === "number") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "bdd.ml", 99, 31 ] ]; } - else if (v === n[2] && idl === getId(n[1]) && idh === getId(n[4])) { + else if (v === n[1] && idl === getId(n[0]) && idh === getId(n[3])) { return n; } else { - _b = b[2]; + _b = b[1]; continue ; } } else { - var n_003 = (++ nodeC[1], nodeC[1]); - var n$1 = [ - /* Node */0, - low, - v, - n_003, - high - ]; + var n_002 = (++ nodeC[0], nodeC[0]); + var n$1 = /* Node */{ + 0: low, + 1: v, + 2: n_002, + 3: high, + length: 4, + tag: 0 + }; insert(getId(low), getId(high), v, ind, bucket, n$1); return n$1; } @@ -246,13 +228,13 @@ function not(n) { } } else { - var id = n[3]; + var id = n[2]; var h = id % cacheSize; if (id === notslot1[h]) { return notslot2[h]; } else { - var f = mkNode(not(n[1]), n[2], not(n[4])); + var f = mkNode(not(n[0]), n[1], not(n[3])); notslot1[h] = id; notslot2[h] = f; return f; @@ -270,10 +252,10 @@ function and2(n1, n2) { } } else { - var r1 = n1[4]; - var i1 = n1[3]; - var v1 = n1[2]; - var l1 = n1[1]; + var r1 = n1[3]; + var i1 = n1[2]; + var v1 = n1[1]; + var l1 = n1[0]; if (typeof n2 === "number") { if (n2 !== 0) { return /* Zero */1; @@ -283,10 +265,10 @@ function and2(n1, n2) { } } else { - var r2 = n2[4]; - var i2 = n2[3]; - var v2 = n2[2]; - var l2 = n2[1]; + var r2 = n2[3]; + var i2 = n2[2]; + var v2 = n2[1]; + var l2 = n2[0]; var h = hash(i1, i2); if (i1 === andslot1[h] && i2 === andslot2[h]) { return andslot3[h]; @@ -325,10 +307,10 @@ function xor(n1, n2) { } } else { - var r1 = n1[4]; - var i1 = n1[3]; - var v1 = n1[2]; - var l1 = n1[1]; + var r1 = n1[3]; + var i1 = n1[2]; + var v1 = n1[1]; + var l1 = n1[0]; if (typeof n2 === "number") { if (n2 !== 0) { return n1; @@ -338,10 +320,10 @@ function xor(n1, n2) { } } else { - var r2 = n2[4]; - var i2 = n2[3]; - var v2 = n2[2]; - var l2 = n2[1]; + var r2 = n2[3]; + var i2 = n2[2]; + var v2 = n2[1]; + var l2 = n2[0]; var h = hash(i1, i2); if (i1 === andslot1[h] && i2 === andslot2[h]) { return andslot3[h]; @@ -390,14 +372,11 @@ function hwb(n) { return h(0, n - 1); } -var seed = [ - 0, - 0 -]; +var seed = [0]; function random() { - seed[1] = seed[1] * 25173 + 17431; - return +((seed[1] & 1) > 0); + seed[0] = seed[0] * 25173 + 17431; + return +((seed[0] & 1) > 0); } function random_vars(n) { @@ -448,10 +427,8 @@ function main() { } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "bdd.ml", 233, 2 diff --git a/jscomp/test/boolean_test.js b/jscomp/test/boolean_test.js index 7a0a7a7159..c5999ad376 100644 --- a/jscomp/test/boolean_test.js +++ b/jscomp/test/boolean_test.js @@ -4,10 +4,8 @@ var Mt = require("./mt"); var Test_bool_equal = require("./test_bool_equal"); -Mt.from_suites("boolean", [ - /* :: */0, - [ - /* tuple */0, +Mt.from_suites("boolean", /* :: */[ + /* tuple */[ "bool_equal", Test_bool_equal.assertions ], diff --git a/jscomp/test/buffer_test.js b/jscomp/test/buffer_test.js index 90a241249e..128cd7ff90 100644 --- a/jscomp/test/buffer_test.js +++ b/jscomp/test/buffer_test.js @@ -12,10 +12,8 @@ var v = "gso"; function bytes_equal() { if (Bytes.make(3, /* "a" */97)[0] !== /* "a" */97) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "buffer_test.ml", 9, 4 @@ -24,10 +22,8 @@ function bytes_equal() { } if (Bytes.make(3, /* "a" */97)[0] !== /* "a" */97) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "buffer_test.ml", 10, 4 @@ -38,10 +34,8 @@ function bytes_equal() { u[0] = /* "b" */98; if (u[0] !== /* "b" */98) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "buffer_test.ml", 13, 4 @@ -53,10 +47,8 @@ function bytes_equal() { } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "buffer_test.ml", 14, 4 @@ -65,16 +57,13 @@ function bytes_equal() { } } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "equal", bytes_equal ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "buffer", function () { var v = Buffer.create(30); @@ -88,10 +77,9 @@ var suites_002 = [ /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_suites("buffer_test.ml", suites); diff --git a/jscomp/test/caml_compare_test.d.ts b/jscomp/test/caml_compare_test.d.ts new file mode 100644 index 0000000000..cab0dc909f --- /dev/null +++ b/jscomp/test/caml_compare_test.d.ts @@ -0,0 +1,2 @@ +export var suites: any ; + diff --git a/jscomp/test/caml_compare_test.js b/jscomp/test/caml_compare_test.js new file mode 100644 index 0000000000..9b74a9dcaf --- /dev/null +++ b/jscomp/test/caml_compare_test.js @@ -0,0 +1,214 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_obj = require("../runtime/caml_obj"); +var Mt = require("./mt"); + +var suites_000 = /* tuple */[ + "option", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_obj.caml_lessthan(/* None */0, /* Some */[1]), + length: 2, + tag: 0 + }; + } +]; + +var suites_001 = /* :: */[ + /* tuple */[ + "option2", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_obj.caml_lessthan(/* Some */[1], /* Some */[2]), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "list0", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_obj.caml_greaterthan(/* :: */[ + 1, + /* [] */0 + ], /* [] */0), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "listeq", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_obj.caml_equal(/* :: */[ + 1, + /* :: */[ + 2, + /* :: */[ + 3, + /* [] */0 + ] + ] + ], /* :: */[ + 1, + /* :: */[ + 2, + /* :: */[ + 3, + /* [] */0 + ] + ] + ]), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "listneq", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_obj.caml_greaterthan(/* :: */[ + 1, + /* :: */[ + 2, + /* :: */[ + 3, + /* [] */0 + ] + ] + ], /* :: */[ + 1, + /* :: */[ + 2, + /* :: */[ + 2, + /* [] */0 + ] + ] + ]), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "custom_u", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_obj.caml_greaterthan(/* tuple */[ + /* A */{ + 0: 3, + length: 1, + tag: 0 + }, + /* B */{ + 0: 2, + 1: /* false */0, + length: 2, + tag: 1 + }, + /* C */{ + 0: 1, + length: 1, + tag: 2 + } + ], /* tuple */[ + /* A */{ + 0: 3, + length: 1, + tag: 0 + }, + /* B */{ + 0: 2, + 1: /* false */0, + length: 2, + tag: 1 + }, + /* C */{ + 0: 0, + length: 1, + tag: 2 + } + ]), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "custom_u2", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_obj.caml_equal(/* tuple */[ + /* A */{ + 0: 3, + length: 1, + tag: 0 + }, + /* B */{ + 0: 2, + 1: /* false */0, + length: 2, + tag: 1 + }, + /* C */{ + 0: 1, + length: 1, + tag: 2 + } + ], /* tuple */[ + /* A */{ + 0: 3, + length: 1, + tag: 0 + }, + /* B */{ + 0: 2, + 1: /* false */0, + length: 2, + tag: 1 + }, + /* C */{ + 0: 1, + length: 1, + tag: 2 + } + ]), + length: 2, + tag: 0 + }; + } + ], + /* [] */0 + ] + ] + ] + ] + ] +]; + +var suites = /* :: */[ + suites_000, + suites_001 +]; + +Mt.from_pair_suites("caml_compare_test.ml", suites); + +exports.suites = suites; +/* Not a pure module */ diff --git a/jscomp/test/caml_compare_test.ml b/jscomp/test/caml_compare_test.ml new file mode 100644 index 0000000000..4b4f192f67 --- /dev/null +++ b/jscomp/test/caml_compare_test.ml @@ -0,0 +1,16 @@ + +type u = A of int | B of int * bool | C of int + +let suites = Mt.[ + "option", (fun _ -> Eq(true, None < Some 1)); + "option2", (fun _ -> Eq(true, Some 1 < Some 2)); + "list0", (fun _ -> Eq(true, [1] > [])); + "listeq", (fun _ -> Eq(true, [1;2;3] = [1;2;3])); + "listneq", (fun _ -> Eq(true, [1;2;3] > [1;2;2])); + "custom_u", (fun _ -> Eq(true, ( A 3 , B (2,false) , C 1) > ( A 3, B (2,false) , C 0 ))); + "custom_u2", (fun _ -> Eq(true, ( A 3 , B (2,false) , C 1) = ( A 3, B (2,false) , C 1 ))); +] +;; + + +Mt.from_pair_suites __FILE__ suites diff --git a/jscomp/test/complex_if_test.js b/jscomp/test/complex_if_test.js index d714bcba83..6737785a0f 100644 --- a/jscomp/test/complex_if_test.js +++ b/jscomp/test/complex_if_test.js @@ -133,21 +133,20 @@ function string_escaped(s) { return Bytes.to_string(escaped(Bytes.of_string(s))); } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "complete_escape", function () { - return [ - /* Eq */0, - Bytes.to_string(escaped(Bytes.of_string("\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"))), - "\\000\\001\\002\\003\\004\\005\\006\\007\\b\\t\\n\\011\\012\\r\\014\\015\\016\\017\\018\\019\\020\\021\\022\\023\\024\\025\\026\\027\\028\\029\\030\\031 !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\127\\128\\129\\130\\131\\132\\133\\134\\135\\136\\137\\138\\139\\140\\141\\142\\143\\144\\145\\146\\147\\148\\149\\150\\151\\152\\153\\154\\155\\156\\157\\158\\159\\160\\161\\162\\163\\164\\165\\166\\167\\168\\169\\170\\171\\172\\173\\174\\175\\176\\177\\178\\179\\180\\181\\182\\183\\184\\185\\186\\187\\188\\189\\190\\191\\192\\193\\194\\195\\196\\197\\198\\199\\200\\201\\202\\203\\204\\205\\206\\207\\208\\209\\210\\211\\212\\213\\214\\215\\216\\217\\218\\219\\220\\221\\222\\223\\224\\225\\226\\227\\228\\229\\230\\231\\232\\233\\234\\235\\236\\237\\238\\239\\240\\241\\242\\243\\244\\245\\246\\247\\248\\249\\250\\251\\252\\253\\254\\255" - ]; + return /* Eq */{ + 0: Bytes.to_string(escaped(Bytes.of_string("\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"))), + 1: "\\000\\001\\002\\003\\004\\005\\006\\007\\b\\t\\n\\011\\012\\r\\014\\015\\016\\017\\018\\019\\020\\021\\022\\023\\024\\025\\026\\027\\028\\029\\030\\031 !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\127\\128\\129\\130\\131\\132\\133\\134\\135\\136\\137\\138\\139\\140\\141\\142\\143\\144\\145\\146\\147\\148\\149\\150\\151\\152\\153\\154\\155\\156\\157\\158\\159\\160\\161\\162\\163\\164\\165\\166\\167\\168\\169\\170\\171\\172\\173\\174\\175\\176\\177\\178\\179\\180\\181\\182\\183\\184\\185\\186\\187\\188\\189\\190\\191\\192\\193\\194\\195\\196\\197\\198\\199\\200\\201\\202\\203\\204\\205\\206\\207\\208\\209\\210\\211\\212\\213\\214\\215\\216\\217\\218\\219\\220\\221\\222\\223\\224\\225\\226\\227\\228\\229\\230\\231\\232\\233\\234\\235\\236\\237\\238\\239\\240\\241\\242\\243\\244\\245\\246\\247\\248\\249\\250\\251\\252\\253\\254\\255", + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/complex_test.js b/jscomp/test/complex_test.js index 30aa42ffd9..6c168a7dfe 100644 --- a/jscomp/test/complex_test.js +++ b/jscomp/test/complex_test.js @@ -4,24 +4,23 @@ var Complex = require("../stdlib/complex"); var Mt = require("./mt"); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "basic_add", function () { - return [ - /* Eq */0, - /* float array */[ + return /* Eq */{ + 0: /* float array */[ 2, 2 ], - Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i) - ]; + 1: Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i), + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/const_block_test.js b/jscomp/test/const_block_test.js index 3da3290e56..4537f395f1 100644 --- a/jscomp/test/const_block_test.js +++ b/jscomp/test/const_block_test.js @@ -3,13 +3,13 @@ var Mt = require("./mt"); -var a = /* array */[ +var a = /* float array */[ 0, 1, 2 ]; -var b = /* array */[ +var b = /* int array */[ 0, 1, 2 @@ -36,38 +36,33 @@ function h() { function g() { f(/* () */0); - return [ - /* Eq */0, - [ - /* tuple */0, + return /* Eq */{ + 0: /* tuple */[ a[0], b[0] ], - [ - /* tuple */0, + 1: /* tuple */[ 3.0, 3 - ] - ]; + ], + length: 2, + tag: 0 + }; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "const_block_test", g ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "avoid_mutable_inline_test", function () { c[0] = 3; c[1] = 4; - return [ - /* Eq */0, - /* array */[ + return /* Eq */{ + 0: /* array */[ 3, 4, 2, @@ -75,23 +70,23 @@ var suites_002 = [ 4, 5 ], - c - ]; + 1: c, + length: 2, + tag: 0 + }; } ], /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("const_block_test.ml", suites); -var v = [ - /* tuple */0, +var v = /* tuple */[ 0, 1, 2, diff --git a/jscomp/test/const_defs_test.js b/jscomp/test/const_defs_test.js index b03a4a2179..b5fdb4cdee 100644 --- a/jscomp/test/const_defs_test.js +++ b/jscomp/test/const_defs_test.js @@ -7,7 +7,6 @@ var u = 3; function f() { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "hi" ]; diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 50705bb640..174460278a 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -8,10 +8,7 @@ var Caml_curry = require("../runtime/caml_curry"); var Assert = require("assert"); function test() { - var v = [ - 0, - 0 - ]; + var v = [0]; var f = function (_n, _acc) { while(true) { var acc = _acc; @@ -19,7 +16,7 @@ function test() { if (n) { _acc = (function(n,acc){ return function () { - v[1] += n; + v[0] += n; return Caml_curry.app1(acc, /* () */0); } }(n,acc)); @@ -35,15 +32,12 @@ function test() { f(10, function () { return /* () */0; }); - return v[1]; + return v[0]; } function test_closure() { var n = 6; - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = Caml_array.caml_make_vect(n, function (x) { return x; }); @@ -55,18 +49,15 @@ function test_closure() { }(i)); } $$Array.iter(function (i) { - v[1] += Caml_curry.app1(i, 0); + v[0] += Caml_curry.app1(i, 0); return /* () */0; }, arr); - return v[1]; + return v[0]; } function test_closure2() { var n = 6; - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = Caml_array.caml_make_vect(n, function (x) { return x; }); @@ -79,36 +70,30 @@ function test_closure2() { }(j)); } $$Array.iter(function (i) { - v[1] += Caml_curry.app1(i, 0); + v[0] += Caml_curry.app1(i, 0); return /* () */0; }, arr); - return v[1]; + return v[0]; } -Mt.from_suites("cps_test.ml", [ - /* :: */0, - [ - /* tuple */0, +Mt.from_suites("cps_test.ml", /* :: */[ + /* tuple */[ "cps_test_sum", function () { var prim = test(/* () */0); return Assert.deepEqual(55, prim); } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "cps_test_closure", function () { var prim = test_closure(/* () */0); return Assert.deepEqual(15, prim); } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "cps_test_closure2", function () { var prim = test_closure2(/* () */0); diff --git a/jscomp/test/demo.js b/jscomp/test/demo.js index ccad794b2e..52a67f97d5 100644 --- a/jscomp/test/demo.js +++ b/jscomp/test/demo.js @@ -7,18 +7,15 @@ var Runtime = require("@runtime"); var Caml_curry = require("../runtime/caml_curry"); var data = /* array */[ - [ - /* record */0, + /* record */[ "GOOG", 700.0 ], - [ - /* record */0, + /* record */[ "AAPL", 500.0 ], - [ - /* record */0, + /* record */[ "MSFT", 300.0 ] @@ -26,14 +23,11 @@ var data = /* array */[ function ui_layout(compile, lookup, appContext) { var init = Caml_curry.app1(compile, "bid - ask"); - var computeFunction = [ - 0, - function (env) { + var computeFunction = [function (env) { return Caml_curry.app1(init, function (key) { return Caml_curry.app2(lookup, env, key); }); - } - ]; + }]; var hw1 = new BUI.HostedWindow(); var hc = new BUI.HostedContent(); var stackPanel = new UI.StackPanel(); @@ -90,7 +84,7 @@ function ui_layout(compile, lookup, appContext) { Caml_curry.app2(button.on, "click", function () { try { var hot_function = Caml_curry.app1(compile, inputCode.text); - computeFunction[1] = function (env) { + computeFunction[0] = function (env) { return Caml_curry.app1(hot_function, function (key) { return Caml_curry.app2(lookup, env, key); }); @@ -103,10 +97,10 @@ function ui_layout(compile, lookup, appContext) { }); Runtime.setInterval(function () { return grid.dataSource = Array.prototype.map.call(data, function (param) { - var price = param[2]; + var price = param[1]; var bid = price + 20 * Math.random(); var ask = price + 20 * Math.random(); - var result = Caml_curry.app1(computeFunction[1], { + var result = Caml_curry.app1(computeFunction[0], { "bid": bid, "ask": ask }); @@ -116,7 +110,7 @@ function ui_layout(compile, lookup, appContext) { return /* array */[ { "label": { - "text": param[1] + "text": param[0] } }, { diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index 13c88f08f3..6a1b17a745 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -24,11 +24,12 @@ function sum(n) { function map(f, param) { if (param) { - return [ - /* Cons */0, - Caml_curry.app1(f, param[1]), - map(f, param[2]) - ]; + return /* Cons */{ + 0: Caml_curry.app1(f, param[0]), + 1: map(f, param[1]), + length: 2, + tag: 0 + }; } else { return /* Nil */0; @@ -45,9 +46,11 @@ function f(param) { ReactDom.render(React.createClass({ "render": function () { - return React.DOM.div({ - "alt": "pic" - }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!")); + return React.DOM.div(/* Some */[{ + "alt": /* Some */["pic"] ? undefined : /* Some */["pic"][1] + }] ? undefined : /* Some */[{ + "alt": /* Some */["pic"] ? undefined : /* Some */["pic"][1] + }][1], React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!")); } }), document.getElementById("hi")); diff --git a/jscomp/test/equal_exception_test.js b/jscomp/test/equal_exception_test.js index d330cb38a0..42904dadaa 100644 --- a/jscomp/test/equal_exception_test.js +++ b/jscomp/test/equal_exception_test.js @@ -10,10 +10,8 @@ var v = "gso"; function is_equal() { if (Bytes.make(3, /* "a" */97)[0] !== /* "a" */97) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "equal_exception_test.ml", 9, 4 @@ -22,10 +20,8 @@ function is_equal() { } if (Bytes.make(3, /* "a" */97)[0] !== /* "a" */97) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "equal_exception_test.ml", 10, 4 @@ -36,10 +32,8 @@ function is_equal() { u[0] = /* "b" */98; if (u[0] !== /* "b" */98) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "equal_exception_test.ml", 13, 4 @@ -51,10 +45,8 @@ function is_equal() { } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "equal_exception_test.ml", 14, 4 @@ -78,13 +70,13 @@ function is_exception() { } function is_normal_exception() { - var A = [ - 248, - "A", - ++ Caml_builtin_exceptions.caml_oo_last_id - ]; + var A = { + 0: "A", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 + }; var v = [ - 0, A, 3 ]; @@ -92,8 +84,8 @@ function is_normal_exception() { throw v; } catch (exn){ - if (exn[1] === A) { - if (exn[2] !== 3) { + if (exn[0] === A) { + if (exn[1] !== 3) { throw exn; } else { @@ -107,11 +99,12 @@ function is_normal_exception() { } function is_arbitrary_exception() { - var A = [ - 248, - "A", - ++ Caml_builtin_exceptions.caml_oo_last_id - ]; + var A = { + 0: "A", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 + }; try { throw A; } @@ -120,30 +113,23 @@ function is_arbitrary_exception() { } } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "is_equal", is_equal ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "is_exception", is_exception ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "is_normal_exception", is_normal_exception ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "is_arbitrary_exception", is_arbitrary_exception ], @@ -152,10 +138,9 @@ var suites_002 = [ ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_suites("exception", suites); diff --git a/jscomp/test/ext_filename.js b/jscomp/test/ext_filename.js index 66566b3ceb..e5dbfd0e96 100644 --- a/jscomp/test/ext_filename.js +++ b/jscomp/test/ext_filename.js @@ -43,15 +43,14 @@ function absolute_path(s) { } function chop_extension($staropt$star, name) { - var loc = $staropt$star ? $staropt$star[1] : ""; + var loc = $staropt$star ? $staropt$star[0] : ""; try { return Filename.chop_extension(name); } catch (exn){ - if (exn[1] === Caml_builtin_exceptions.Invalid_argument) { + if (exn[0] === Caml_builtin_exceptions.Invalid_argument) { var s = "Filename.chop_extension (" + (loc + (":" + (name + ")"))); throw [ - 0, Caml_builtin_exceptions.Invalid_argument, s ]; @@ -81,9 +80,9 @@ function relative_path(file1, file2) { var exit = 0; if (dir1) { if (dir2) { - if (dir1[1] === dir2[1]) { - _dir2 = dir2[2]; - _dir1 = dir1[2]; + if (dir1[0] === dir2[0]) { + _dir2 = dir2[1]; + _dir1 = dir1[1]; continue ; } @@ -108,20 +107,18 @@ function relative_path(file1, file2) { }; var ys = go(dir1, dir2); if (ys) { - if (ys[1] === node_parent) { + if (ys[0] === node_parent) { return $$String.concat(node_sep, ys); } else { - return $$String.concat(node_sep, [ - /* :: */0, + return $$String.concat(node_sep, /* :: */[ node_current, ys ]); } } else { - return $$String.concat(node_sep, [ - /* :: */0, + return $$String.concat(node_sep, /* :: */[ node_current, ys ]); diff --git a/jscomp/test/ext_list.js b/jscomp/test/ext_list.js index cd51438151..48234228b2 100644 --- a/jscomp/test/ext_list.js +++ b/jscomp/test/ext_list.js @@ -10,12 +10,11 @@ function filter_map(f, _xs) { while(true) { var xs = _xs; if (xs) { - var ys = xs[2]; - var match = Caml_curry.app1(f, xs[1]); + var ys = xs[1]; + var match = Caml_curry.app1(f, xs[0]); if (match) { - return [ - /* :: */0, - match[1], + return /* :: */[ + match[0], filter_map(f, ys) ]; } @@ -37,8 +36,8 @@ function same_length(_xs, _ys) { var xs = _xs; if (xs) { if (ys) { - _ys = ys[2]; - _xs = xs[2]; + _ys = ys[1]; + _xs = xs[1]; continue ; } @@ -61,12 +60,11 @@ function filter_mapi(f, xs) { var xs = _xs; var i = _i; if (xs) { - var ys = xs[2]; - var match = Caml_curry.app2(f, i, xs[1]); + var ys = xs[1]; + var match = Caml_curry.app2(f, i, xs[0]); if (match) { - return [ - /* :: */0, - match[1], + return /* :: */[ + match[0], aux(i + 1, ys) ]; } @@ -91,13 +89,12 @@ function filter_map2(f, _xs, _ys) { var xs = _xs; if (xs) { if (ys) { - var vs = ys[2]; - var us = xs[2]; - var match = Caml_curry.app2(f, xs[1], ys[1]); + var vs = ys[1]; + var us = xs[1]; + var match = Caml_curry.app2(f, xs[0], ys[0]); if (match) { - return [ - /* :: */0, - match[1], + return /* :: */[ + match[0], filter_map2(f, us, vs) ]; } @@ -110,7 +107,6 @@ function filter_map2(f, _xs, _ys) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.filter_map2" ]; @@ -118,7 +114,6 @@ function filter_map2(f, _xs, _ys) { } else if (ys) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.filter_map2" ]; @@ -137,13 +132,12 @@ function filter_map2i(f, xs, ys) { var i = _i; if (xs) { if (ys) { - var vs = ys[2]; - var us = xs[2]; - var match = Caml_curry.app3(f, i, xs[1], ys[1]); + var vs = ys[1]; + var us = xs[1]; + var match = Caml_curry.app3(f, i, xs[0], ys[0]); if (match) { - return [ - /* :: */0, - match[1], + return /* :: */[ + match[0], aux(i + 1, us, vs) ]; } @@ -157,7 +151,6 @@ function filter_map2i(f, xs, ys) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.filter_map2i" ]; @@ -165,7 +158,6 @@ function filter_map2i(f, xs, ys) { } else if (ys) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.filter_map2i" ]; @@ -183,12 +175,11 @@ function rev_map_append(f, _l1, _l2) { var l2 = _l2; var l1 = _l1; if (l1) { - _l2 = [ - /* :: */0, - Caml_curry.app1(f, l1[1]), + _l2 = /* :: */[ + Caml_curry.app1(f, l1[0]), l2 ]; - _l1 = l1[2]; + _l1 = l1[1]; continue ; } @@ -208,15 +199,14 @@ function flat_map2(f, lx, ly) { var acc = _acc; if (lx$1) { if (ly$1) { - _ly = ly$1[2]; - _lx = lx$1[2]; - _acc = List.rev_append(Caml_curry.app2(f, lx$1[1], ly$1[1]), acc); + _ly = ly$1[1]; + _lx = lx$1[1]; + _acc = List.rev_append(Caml_curry.app2(f, lx$1[0], ly$1[0]), acc); continue ; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.flat_map2" ]; @@ -224,7 +214,6 @@ function flat_map2(f, lx, ly) { } else if (ly$1) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.flat_map2" ]; @@ -242,8 +231,8 @@ function flat_map(f, lx) { var lx$1 = _lx; var acc = _acc; if (lx$1) { - _lx = lx$1[2]; - _acc = List.rev_append(Caml_curry.app1(f, lx$1[1]), acc); + _lx = lx$1[1]; + _acc = List.rev_append(Caml_curry.app1(f, lx$1[0]), acc); continue ; } @@ -255,43 +244,39 @@ function flat_map(f, lx) { function map2_last(f, l1, l2) { if (l1) { - var l1$1 = l1[2]; - var u = l1[1]; + var l1$1 = l1[1]; + var u = l1[0]; var exit = 0; if (l1$1) { exit = 1; } else if (l2) { - if (l2[2]) { + if (l2[1]) { exit = 1; } else { - return [ - /* :: */0, - Caml_curry.app3(f, /* true */1, u, l2[1]), + return /* :: */[ + Caml_curry.app3(f, /* true */1, u, l2[0]), /* [] */0 ]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.map2_last" ]; } if (exit === 1) { if (l2) { - var r = Caml_curry.app3(f, /* false */0, u, l2[1]); - return [ - /* :: */0, + var r = Caml_curry.app3(f, /* false */0, u, l2[0]); + return /* :: */[ r, - map2_last(f, l1$1, l2[2]) + map2_last(f, l1$1, l2[1]) ]; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.map2_last" ]; @@ -301,7 +286,6 @@ function map2_last(f, l1, l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.map2_last" ]; @@ -313,19 +297,17 @@ function map2_last(f, l1, l2) { function map_last(f, l1) { if (l1) { - var l1$1 = l1[2]; - var u = l1[1]; + var l1$1 = l1[1]; + var u = l1[0]; if (l1$1) { var r = Caml_curry.app2(f, /* false */0, u); - return [ - /* :: */0, + return /* :: */[ r, map_last(f, l1$1) ]; } else { - return [ - /* :: */0, + return /* :: */[ Caml_curry.app2(f, /* true */1, u), /* [] */0 ]; @@ -349,14 +331,12 @@ function take(n, l) { var arr_length = arr.length; if (arr_length < n) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.take" ]; } else { - return [ - /* tuple */0, + return /* tuple */[ $$Array.to_list($$Array.sub(arr, 0, n)), $$Array.to_list($$Array.sub(arr, n, arr_length - n)) ]; @@ -370,12 +350,11 @@ function exclude_tail(x) { var x$1 = _x; var acc = _acc; if (x$1) { - var ys = x$1[2]; + var ys = x$1[1]; if (ys) { _x = ys; - _acc = [ - /* :: */0, - x$1[1], + _acc = /* :: */[ + x$1[0], acc ]; continue ; @@ -387,7 +366,6 @@ function exclude_tail(x) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.exclude_tail" ]; @@ -397,7 +375,7 @@ function exclude_tail(x) { function group(cmp, lst) { if (lst) { - return aux(cmp, lst[1], group(cmp, lst[2])); + return aux(cmp, lst[0], group(cmp, lst[1])); } else { return /* [] */0; @@ -406,13 +384,11 @@ function group(cmp, lst) { function aux(cmp, x, xss) { if (xss) { - var ys = xss[2]; - var y = xss[1]; + var ys = xss[1]; + var y = xss[0]; if (Caml_curry.app2(cmp, x, List.hd(y))) { - return [ - /* :: */0, - [ - /* :: */0, + return /* :: */[ + /* :: */[ x, y ], @@ -420,18 +396,15 @@ function aux(cmp, x, xss) { ]; } else { - return [ - /* :: */0, + return /* :: */[ y, aux(cmp, x, ys) ]; } } else { - return [ - /* :: */0, - [ - /* :: */0, + return /* :: */[ + /* :: */[ x, /* [] */0 ], @@ -450,7 +423,6 @@ function drop(_n, _h) { var n = _n; if (n < 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.drop" ]; @@ -464,7 +436,6 @@ function drop(_n, _h) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Ext_list.drop" ]; @@ -480,17 +451,14 @@ function for_all_ret(p, _param) { while(true) { var param = _param; if (param) { - var a = param[1]; + var a = param[0]; if (Caml_curry.app1(p, a)) { - _param = param[2]; + _param = param[1]; continue ; } else { - return [ - /* Some */0, - a - ]; + return /* Some */[a]; } } else { @@ -503,12 +471,12 @@ function for_all_opt(p, _param) { while(true) { var param = _param; if (param) { - var v = Caml_curry.app1(p, param[1]); + var v = Caml_curry.app1(p, param[0]); if (v) { return v; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -532,10 +500,9 @@ function rev_map_acc(acc, f, l) { var param = _param; var accu = _accu; if (param) { - _param = param[2]; - _accu = [ - /* :: */0, - Caml_curry.app1(f, param[1]), + _param = param[1]; + _accu = /* :: */[ + Caml_curry.app1(f, param[0]), accu ]; continue ; @@ -549,8 +516,8 @@ function rev_map_acc(acc, f, l) { function rev_iter(f, xs) { if (xs) { - rev_iter(f, xs[2]); - return Caml_curry.app1(f, xs[1]); + rev_iter(f, xs[1]); + return Caml_curry.app1(f, xs[0]); } else { return /* () */0; diff --git a/jscomp/test/ext_string.js b/jscomp/test/ext_string.js index 195fff9a9a..3c9ba3d649 100644 --- a/jscomp/test/ext_string.js +++ b/jscomp/test/ext_string.js @@ -8,7 +8,7 @@ var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); function split_by($staropt$star, is_delim, str) { - var keep_empty = $staropt$star ? $staropt$star[1] : /* false */0; + var keep_empty = $staropt$star ? $staropt$star[0] : /* false */0; var len = str.length; var _acc = /* [] */0; var _last_pos = len; @@ -18,8 +18,7 @@ function split_by($staropt$star, is_delim, str) { var last_pos = _last_pos; var acc = _acc; if (pos === -1) { - return [ - /* :: */0, + return /* :: */[ $$String.sub(str, 0, last_pos), acc ]; @@ -30,8 +29,7 @@ function split_by($staropt$star, is_delim, str) { var v = $$String.sub(str, pos + 1, new_len); _pos = pos - 1; _last_pos = pos; - _acc = [ - /* :: */0, + _acc = /* :: */[ v, acc ]; @@ -132,12 +130,7 @@ function escaped(s) { } } - else if (match >= 11) { - match !== 13; - return /* true */1; - } else { - match >= 8; return /* true */1; } } diff --git a/jscomp/test/for_loop_test.js b/jscomp/test/for_loop_test.js index e821b0a5d6..53ecf2e50d 100644 --- a/jscomp/test/for_loop_test.js +++ b/jscomp/test/for_loop_test.js @@ -7,10 +7,7 @@ var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); function for_3(x) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); @@ -18,7 +15,7 @@ function for_3(x) { var j = i * 2; arr[i] = (function(j){ return function () { - v[1] += j; + v[0] += j; return /* () */0; } }(j)); @@ -26,14 +23,11 @@ function for_3(x) { $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_4(x) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); @@ -42,7 +36,7 @@ function for_4(x) { var k = 2 * j; arr[i] = (function(k){ return function () { - v[1] += k; + v[0] += k; return /* () */0; } }(k)); @@ -50,14 +44,11 @@ function for_4(x) { $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_5(x, u) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); @@ -65,7 +56,7 @@ function for_5(x, u) { var k = 2 * u * u; arr[i] = (function(k){ return function () { - v[1] += k; + v[0] += k; return /* () */0; } }(k)); @@ -73,55 +64,43 @@ function for_5(x, u) { $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_6(x, u) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); - var v4 = [ - 0, - 0 - ]; - var v5 = [ - 0, - 0 - ]; + var v4 = [0]; + var v5 = [0]; var inspect_3 = -1; - ++ v4[1]; + ++ v4[0]; for(var j = 0; j<= 1; ++j){ - ++ v5[1]; - var v2 = [ - 0, - 0 - ]; + ++ v5[0]; + var v2 = [0]; (function(v2){ for(var i = 0 ,i_finish = x.length - 1; i<= i_finish; ++i){ var k = 2 * u * u; - var h = 2 * v5[1]; - ++ v2[1]; + var h = 2 * v5[0]; + ++ v2[0]; arr[i] = (function(k,h){ return function () { - v[1] = v[1] + k + v2[1] + v4[1] + v5[1] + h + u; + v[0] = v[0] + k + v2[0] + v4[0] + v5[0] + h + u; return /* () */0; } }(k,h)); } }(v2)); - inspect_3 = v2[1]; + inspect_3 = v2[0]; } $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return /* array */[ - v[1], - v4[1], - v5[1], + return /* int array */[ + v[0], + v4[0], + v5[0], inspect_3 ]; } @@ -129,10 +108,7 @@ function for_6(x, u) { function for_7() { var i_len = 7; var j_len = 3; - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = Caml_array.caml_make_vect(i_len * j_len, function () { return /* () */0; }); @@ -141,7 +117,7 @@ function for_7() { for(var j = 0 ,j_finish = j_len - 1; j<= j_finish; ++j){ arr[i * j_len + j] = (function(j){ return function () { - v[1] = v[1] + i + j; + v[0] = v[0] + i + j; return /* () */0; } }(j)); @@ -151,16 +127,13 @@ function for_7() { $$Array.iter(function (f) { return Caml_curry.app1(f, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_8() { var i_len = 7; var j_len = 3; - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = Caml_array.caml_make_vect(i_len * j_len, function () { return /* () */0; }); @@ -171,7 +144,7 @@ function for_8() { var h = i + j; arr[i * j_len + j] = (function(j,h){ return function () { - v[1] = v[1] + i + j + h + k; + v[0] = v[0] + i + j + h + k; return /* () */0; } }(j,h)); @@ -181,36 +154,26 @@ function for_8() { $$Array.iter(function (f) { return Caml_curry.app1(f, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_9() { - var v = [ - 0, - /* [] */0 - ]; - var match_001 = function (x) { - v[1] = [ - /* :: */0, + var v = [/* [] */0]; + var match_000 = function (x) { + v[0] = /* :: */[ x, - v[1] + v[0] ]; return /* () */0; }; - var match_002 = function () { - return $$Array.of_list(List.rev(v[1])); + var match_001 = function () { + return $$Array.of_list(List.rev(v[0])); }; - var collect = match_001; + var collect = match_000; var i_len = 2; var j_len = 2; - var vv = [ - 0, - 0 - ]; - var vv2 = [ - 0, - 0 - ]; + var vv = [0]; + var vv2 = [0]; var arr = Caml_array.caml_make_vect(i_len * j_len, function () { return /* () */0; }); @@ -218,24 +181,21 @@ function for_9() { return /* () */0; }); for(var i = 0 ,i_finish = i_len - 1; i<= i_finish; ++i){ - var v$1 = [ - 0, - 0 - ]; - v$1[1] += i; + var v$1 = [0]; + v$1[0] += i; (function(v$1){ for(var j = 0 ,j_finish = j_len - 1; j<= j_finish; ++j){ - ++ v$1[1]; - Caml_curry.app1(collect, v$1[1]); + ++ v$1[0]; + Caml_curry.app1(collect, v$1[0]); arr[i * j_len + j] = function () { - vv[1] += v$1[1]; + vv[0] += v$1[0]; return /* () */0; }; } }(v$1)); arr2[i] = (function(v$1){ return function () { - vv2[1] += v$1[1]; + vv2[0] += v$1[0]; return /* () */0; } }(v$1)); @@ -246,108 +206,98 @@ function for_9() { $$Array.iter(function (f) { return Caml_curry.app1(f, /* () */0); }, arr2); - return /* array */[[ - /* tuple */0, - vv[1], - Caml_curry.app1(match_002, /* () */0), - vv2[1] + return /* array */[/* tuple */[ + vv[0], + Caml_curry.app1(match_001, /* () */0), + vv2[0] ]]; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "for_loop_test_3", function () { - return [ - /* Eq */0, - 90, - for_3(Caml_array.caml_make_vect(10, 2)) - ]; + return /* Eq */{ + 0: 90, + 1: for_3(Caml_array.caml_make_vect(10, 2)), + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "for_loop_test_4", function () { - return [ - /* Eq */0, - 180, - for_4(Caml_array.caml_make_vect(10, 2)) - ]; + return /* Eq */{ + 0: 180, + 1: for_4(Caml_array.caml_make_vect(10, 2)), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "for_loop_test_5", function () { - return [ - /* Eq */0, - 2420, - for_5(Caml_array.caml_make_vect(10, 2), 11) - ]; + return /* Eq */{ + 0: 2420, + 1: for_5(Caml_array.caml_make_vect(10, 2), 11), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "for_loop_test_6", function () { - return [ - /* Eq */0, - /* array */[ + return /* Eq */{ + 0: /* int array */[ 30, 1, 2, 3 ], - for_6(Caml_array.caml_make_vect(3, 0), 0) - ]; + 1: for_6(Caml_array.caml_make_vect(3, 0), 0), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "for_loop_test_7", function () { - return [ - /* Eq */0, - 84, - for_7(/* () */0) - ]; + return /* Eq */{ + 0: 84, + 1: for_7(/* () */0), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "for_loop_test_8", function () { - return [ - /* Eq */0, - 294, - for_8(/* () */0) - ]; + return /* Eq */{ + 0: 294, + 1: for_8(/* () */0), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "for_loop_test_9", function () { - return [ - /* Eq */0, - /* array */[[ - /* tuple */0, + return /* Eq */{ + 0: /* array */[/* tuple */[ 10, - /* array */[ + /* int array */[ 1, 2, 2, @@ -355,8 +305,10 @@ var suites_002 = [ ], 5 ]], - for_9(/* () */0) - ]; + 1: for_9(/* () */0), + length: 2, + tag: 0 + }; } ], /* [] */0 @@ -367,10 +319,9 @@ var suites_002 = [ ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; exports.for_3 = for_3; diff --git a/jscomp/test/for_side_effect_test.js b/jscomp/test/for_side_effect_test.js index 04b2efcc1d..ae20f24897 100644 --- a/jscomp/test/for_side_effect_test.js +++ b/jscomp/test/for_side_effect_test.js @@ -21,8 +21,7 @@ function test2() { return v; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "for_order", function () { var prim = test2(/* () */0); @@ -30,9 +29,8 @@ var suites_001 = [ } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/format_regression.js b/jscomp/test/format_regression.js index d95a8b81ae..dfc29fd676 100644 --- a/jscomp/test/format_regression.js +++ b/jscomp/test/format_regression.js @@ -6,10 +6,8 @@ var Caml_curry = require("../runtime/caml_curry"); function peek_queue() { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "format_regression.ml", 10, 19 @@ -19,10 +17,8 @@ function peek_queue() { function int_of_size() { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "format_regression.ml", 11, 20 @@ -32,10 +28,8 @@ function int_of_size() { function take_queue() { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "format_regression.ml", 12, 19 @@ -45,10 +39,8 @@ function take_queue() { function format_pp_token(_, _$1) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "format_regression.ml", 13, 26 @@ -60,16 +52,16 @@ var pp_infinity = 1000000010; function advance_loop(state) { while(true) { - var match = peek_queue(state[4]); - var size = match[1]; + var match = peek_queue(state[3]); + var size = match[0]; var size$1 = int_of_size(size); - if (size$1 < 0 && state[3] - state[2] < state[1]) { + if (size$1 < 0 && state[2] - state[1] < state[0]) { return 0; } else { - take_queue(state[4]); - Caml_curry.app1(format_pp_token(state, size$1 < 0 ? pp_infinity : size$1), match[2]); - state[2] = match[3] + state[2]; + take_queue(state[3]); + Caml_curry.app1(format_pp_token(state, size$1 < 0 ? pp_infinity : size$1), match[1]); + state[1] = match[2] + state[1]; continue ; } diff --git a/jscomp/test/genlex_test.js b/jscomp/test/genlex_test.js index 93783b5a9f..5b99f33d46 100644 --- a/jscomp/test/genlex_test.js +++ b/jscomp/test/genlex_test.js @@ -6,29 +6,21 @@ var Mt = require("./mt"); var Genlex = require("../stdlib/genlex"); var List = require("../stdlib/list"); -var lexer = Genlex.make_lexer([ - /* :: */0, +var lexer = Genlex.make_lexer(/* :: */[ "+", - [ - /* :: */0, + /* :: */[ "-", - [ - /* :: */0, + /* :: */[ "*", - [ - /* :: */0, + /* :: */[ "/", - [ - /* :: */0, + /* :: */[ "let", - [ - /* :: */0, + /* :: */[ "=", - [ - /* :: */0, + /* :: */[ "(", - [ - /* :: */0, + /* :: */[ ")", /* [] */0 ] @@ -59,8 +51,7 @@ function to_list(s) { } } if (exit === 1) { - _acc = [ - /* :: */0, + _acc = /* :: */[ v, acc ]; @@ -71,54 +62,52 @@ function to_list(s) { }; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "lexer_stream_genlex", function () { - return [ - /* Eq */0, - [ - /* :: */0, - [ - /* Int */2, - 3 - ], - [ - /* :: */0, - [ - /* Kwd */0, - "(" - ], - [ - /* :: */0, - [ - /* Int */2, - 3 - ], - [ - /* :: */0, - [ - /* Kwd */0, - "+" - ], - [ - /* :: */0, - [ - /* Int */2, - 2 - ], - [ - /* :: */0, - [ - /* Int */2, - -1 - ], - [ - /* :: */0, - [ - /* Kwd */0, - ")" - ], + return /* Eq */{ + 0: /* :: */[ + /* Int */{ + 0: 3, + length: 1, + tag: 2 + }, + /* :: */[ + /* Kwd */{ + 0: "(", + length: 1, + tag: 0 + }, + /* :: */[ + /* Int */{ + 0: 3, + length: 1, + tag: 2 + }, + /* :: */[ + /* Kwd */{ + 0: "+", + length: 1, + tag: 0 + }, + /* :: */[ + /* Int */{ + 0: 2, + length: 1, + tag: 2 + }, + /* :: */[ + /* Int */{ + 0: -1, + length: 1, + tag: 2 + }, + /* :: */[ + /* Kwd */{ + 0: ")", + length: 1, + tag: 0 + }, /* [] */0 ] ] @@ -127,14 +116,15 @@ var suites_001 = [ ] ] ], - to_list(lexer(Stream.of_string("3(3 + 2 -1)"))) - ]; + 1: to_list(lexer(Stream.of_string("3(3 + 2 -1)"))), + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/global_exception_regression_test.js b/jscomp/test/global_exception_regression_test.js index d788e39256..86b6fc030a 100644 --- a/jscomp/test/global_exception_regression_test.js +++ b/jscomp/test/global_exception_regression_test.js @@ -10,38 +10,36 @@ var u = Caml_builtin_exceptions.Not_found; var s = Caml_builtin_exceptions.End_of_file; -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "not_found_equal", function () { - return [ - /* Eq */0, - u, - v - ]; + return /* Eq */{ + 0: u, + 1: v, + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "not_found_not_equal_end_of_file", function () { - return [ - /* Neq */1, - u, - s - ]; + return /* Neq */{ + 0: u, + 1: s, + length: 2, + tag: 1 + }; } ], /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("global_exception_regression_test.ml", suites); diff --git a/jscomp/test/google_closure_test.js b/jscomp/test/google_closure_test.js index 84332dcc7f..13fb9ad9be 100644 --- a/jscomp/test/google_closure_test.js +++ b/jscomp/test/google_closure_test.js @@ -5,25 +5,21 @@ var Assert = require("assert"); var Mt = require("./mt"); var Test_google_closure = require("./test_google_closure"); -Mt.from_suites("Closure", [ - /* :: */0, - [ - /* tuple */0, +Mt.from_suites("Closure", /* :: */[ + /* tuple */[ "partial", function () { - var prim_003 = /* array */[ + var prim_002 = /* int array */[ 1, 2, 3 ]; - var prim = [ - /* tuple */0, + var prim = /* tuple */[ "3", 101, - prim_003 + prim_002 ]; - var prim$1 = [ - /* tuple */0, + var prim$1 = /* tuple */[ Test_google_closure.a, Test_google_closure.b, Test_google_closure.c diff --git a/jscomp/test/guide_for_ext.d.ts b/jscomp/test/guide_for_ext.d.ts new file mode 100644 index 0000000000..b6834c0e6d --- /dev/null +++ b/jscomp/test/guide_for_ext.d.ts @@ -0,0 +1,2 @@ +export var mk: (param : any) => any ; + diff --git a/jscomp/test/guide_for_ext.js b/jscomp/test/guide_for_ext.js new file mode 100644 index 0000000000..1e2859a3bd --- /dev/null +++ b/jscomp/test/guide_for_ext.js @@ -0,0 +1,13 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + + +function mk() { + return { + "text": 32, + "label": "hel" + }; +} + +exports.mk = mk; +/* No side effect */ diff --git a/jscomp/test/guide_for_ext.ml b/jscomp/test/guide_for_ext.ml new file mode 100644 index 0000000000..13ff3120d0 --- /dev/null +++ b/jscomp/test/guide_for_ext.ml @@ -0,0 +1,16 @@ + +(** +[%js{ text : 32 ; label : "hel" }] +Attention: also ok for nested case +*) + +let mk () = + let module N = struct + external mk : text: 'b -> label : 'a -> < + text : 'b; + label : 'a + > = "" + [@@js.obj] + end in + + N.mk ~text:32 ~label:"hel" diff --git a/jscomp/test/hashtbl_test.js b/jscomp/test/hashtbl_test.js index 4bb266d18a..dd786452d2 100644 --- a/jscomp/test/hashtbl_test.js +++ b/jscomp/test/hashtbl_test.js @@ -1,18 +1,16 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Hashtbl = require("../stdlib/hashtbl"); -var Mt = require("./mt"); -var Caml_primitive = require("../runtime/caml_primitive"); -var $$Array = require("../stdlib/array"); -var List = require("../stdlib/list"); +var Caml_obj = require("../runtime/caml_obj"); +var Hashtbl = require("../stdlib/hashtbl"); +var Mt = require("./mt"); +var $$Array = require("../stdlib/array"); +var List = require("../stdlib/list"); function to_list(tbl) { return Hashtbl.fold(function (k, v, acc) { - return [ - /* :: */0, - [ - /* tuple */0, + return /* :: */[ + /* tuple */[ k, v ], @@ -26,7 +24,7 @@ function f() { Hashtbl.add(tbl, 1, /* "1" */49); Hashtbl.add(tbl, 2, /* "2" */50); return List.sort(function (param, param$1) { - return Caml_primitive.caml_int_compare(param[1], param$1[1]); + return Caml_obj.caml_int_compare(param[0], param$1[0]); }, to_list(tbl)); } @@ -40,65 +38,58 @@ function g(count) { } var v = to_list(tbl); return $$Array.of_list(List.sort(function (param, param$1) { - return Caml_primitive.caml_int_compare(param[1], param$1[1]); + return Caml_obj.caml_int_compare(param[0], param$1[0]); }, v)); } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "simple", function () { - return [ - /* Eq */0, - [ - /* :: */0, - [ - /* tuple */0, + return /* Eq */{ + 0: /* :: */[ + /* tuple */[ 1, /* "1" */49 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 2, /* "2" */50 ], /* [] */0 ] ], - f(/* () */0) - ]; + 1: f(/* () */0), + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "more_iterations", function () { var count = 1000; - return [ - /* Eq */0, - $$Array.init(count + 1, function (i) { - return [ - /* tuple */0, + return /* Eq */{ + 0: $$Array.init(count + 1, function (i) { + return /* tuple */[ 2 * i, "" + i ]; }), - g(count) - ]; + 1: g(count), + length: 2, + tag: 0 + }; } ], /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("hashtbl_test.ml", suites); diff --git a/jscomp/test/inline_regression_test.js b/jscomp/test/inline_regression_test.js index 7ae2c9a68a..558c5cdad5 100644 --- a/jscomp/test/inline_regression_test.js +++ b/jscomp/test/inline_regression_test.js @@ -50,21 +50,20 @@ function basename(param) { }, Filename.current_dir_name, param); } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "basename", function () { - return [ - /* Eq */0, - basename("b/c/a.b"), - "a.b" - ]; + return /* Eq */{ + 0: basename("b/c/a.b"), + 1: "a.b", + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/int_map.js b/jscomp/test/int_map.js index a5a7450bc8..d0b5eca123 100644 --- a/jscomp/test/int_map.js +++ b/jscomp/test/int_map.js @@ -2,12 +2,12 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_obj = require("../runtime/caml_obj"); var Caml_curry = require("../runtime/caml_curry"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -17,45 +17,46 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function singleton(x, d) { - return [ - /* Node */0, - /* Empty */0, - x, - d, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: d, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -63,7 +64,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -71,19 +71,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -91,21 +90,21 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } @@ -120,11 +119,11 @@ function is_empty(param) { function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -134,25 +133,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -160,14 +161,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -180,9 +181,9 @@ function mem(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } @@ -200,17 +201,16 @@ function min_binding(_param) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -224,17 +224,16 @@ function max_binding(_param) { while(true) { var param = _param; if (param) { - var r = param[4]; + var r = param[3]; if (r) { _param = r; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -246,17 +245,16 @@ function max_binding(_param) { function remove_min_binding(param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal(remove_min_binding(l), param[2], param[3], param[4]); + return bal(remove_min_binding(l), param[1], param[2], param[3]); } else { - return param[4]; + return param[3]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.remove_min_elt" ]; @@ -265,11 +263,11 @@ function remove_min_binding(param) { function remove(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, d, r); @@ -284,7 +282,7 @@ function remove(x, param) { if (t1) { if (t2) { var match = min_binding(t2); - return bal(t1, match[1], match[2], remove_min_binding(t2)); + return bal(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -304,9 +302,9 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - iter(f, param[1]); - Caml_curry.app2(f, param[2], param[3]); - _param = param[4]; + iter(f, param[0]); + Caml_curry.app2(f, param[1], param[2]); + _param = param[3]; continue ; } @@ -318,17 +316,18 @@ function iter(f, _param) { function map(f, param) { if (param) { - var l$prime = map(f, param[1]); - var d$prime = Caml_curry.app1(f, param[3]); - var r$prime = map(f, param[4]); - return [ - /* Node */0, - l$prime, - param[2], - d$prime, - r$prime, - param[5] - ]; + var l$prime = map(f, param[0]); + var d$prime = Caml_curry.app1(f, param[2]); + var r$prime = map(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: param[1], + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -337,18 +336,19 @@ function map(f, param) { function mapi(f, param) { if (param) { - var v = param[2]; - var l$prime = mapi(f, param[1]); - var d$prime = Caml_curry.app2(f, v, param[3]); - var r$prime = mapi(f, param[4]); - return [ - /* Node */0, - l$prime, - v, - d$prime, - r$prime, - param[5] - ]; + var v = param[1]; + var l$prime = mapi(f, param[0]); + var d$prime = Caml_curry.app2(f, v, param[2]); + var r$prime = mapi(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: v, + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -360,8 +360,8 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold(f, m[0], accu)); + _m = m[3]; continue ; } @@ -375,9 +375,9 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { - if (for_all(p, param[1])) { - _param = param[4]; + if (Caml_curry.app2(p, param[1], param[2])) { + if (for_all(p, param[0])) { + _param = param[3]; continue ; } @@ -399,14 +399,14 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { + if (Caml_curry.app2(p, param[1], param[2])) { return /* true */1; } - else if (exists(p, param[1])) { + else if (exists(p, param[0])) { return /* true */1; } else { - _param = param[4]; + _param = param[3]; continue ; } @@ -419,7 +419,7 @@ function exists(p, _param) { function add_min_binding(k, v, param) { if (param) { - return bal(add_min_binding(k, v, param[1]), param[2], param[3], param[4]); + return bal(add_min_binding(k, v, param[0]), param[1], param[2], param[3]); } else { return singleton(k, v); @@ -428,7 +428,7 @@ function add_min_binding(k, v, param) { function add_max_binding(k, v, param) { if (param) { - return bal(param[1], param[2], param[3], add_max_binding(k, v, param[4])); + return bal(param[0], param[1], param[2], add_max_binding(k, v, param[3])); } else { return singleton(k, v); @@ -438,13 +438,13 @@ function add_max_binding(k, v, param) { function join(l, v, d, r) { if (l) { if (r) { - var rh = r[5]; - var lh = l[5]; + var rh = r[4]; + var lh = l[4]; if (lh > rh + 2) { - return bal(l[1], l[2], l[3], join(l[4], v, d, r)); + return bal(l[0], l[1], l[2], join(l[3], v, d, r)); } else if (rh > lh + 2) { - return bal(join(l, v, d, r[1]), r[2], r[3], r[4]); + return bal(join(l, v, d, r[0]), r[1], r[2], r[3]); } else { return create(l, v, d, r); @@ -463,7 +463,7 @@ function concat(t1, t2) { if (t1) { if (t2) { var match = min_binding(t2); - return join(t1, match[1], match[2], remove_min_binding(t2)); + return join(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -476,7 +476,7 @@ function concat(t1, t2) { function concat_or_join(t1, v, d, t2) { if (d) { - return join(t1, v, d[1], t2); + return join(t1, v, d[0], t2); } else { return concat(t1, t2); @@ -485,46 +485,39 @@ function concat_or_join(t1, v, d, t2) { function split(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { var match = split(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join(match[3], v, d, r) + join(match[2], v, d, r) ]; } else { var match$1 = split(x, r); - return [ - /* tuple */0, - join(l, v, d, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, - [ - /* Some */0, - d - ], + /* Some */[d], r ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* None */0, /* Empty */0 @@ -535,13 +528,10 @@ function split(x, param) { function merge(f, s1, s2) { var exit = 0; if (s1) { - var v1 = s1[2]; - if (s1[5] >= height(s2)) { + var v1 = s1[1]; + if (s1[4] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, Caml_curry.app3(f, v1, [ - /* Some */0, - s1[3] - ], match[2]), merge(f, s1[4], match[3])); + return concat_or_join(merge(f, s1[0], match[0]), v1, Caml_curry.app3(f, v1, /* Some */[s1[2]], match[1]), merge(f, s1[3], match[2])); } else { exit = 1; @@ -555,19 +545,14 @@ function merge(f, s1, s2) { } if (exit === 1) { if (s2) { - var v2 = s2[2]; + var v2 = s2[1]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, Caml_curry.app3(f, v2, match$1[2], [ - /* Some */0, - s2[3] - ]), merge(f, match$1[3], s2[4])); + return concat_or_join(merge(f, match$1[0], s2[0]), v2, Caml_curry.app3(f, v2, match$1[1], /* Some */[s2[2]]), merge(f, match$1[2], s2[3])); } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map.ml", 270, 10 @@ -580,11 +565,11 @@ function merge(f, s1, s2) { function filter(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var l$prime = filter(p, param[1]); + var d = param[2]; + var v = param[1]; + var l$prime = filter(p, param[0]); var pvd = Caml_curry.app2(p, v, d); - var r$prime = filter(p, param[4]); + var r$prime = filter(p, param[3]); if (pvd) { return join(l$prime, v, d, r$prime); } @@ -599,33 +584,30 @@ function filter(p, param) { function partition(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var match = partition(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var d = param[2]; + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pvd = Caml_curry.app2(p, v, d); - var match$1 = partition(p, param[4]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition(p, param[3]); + var rf = match$1[1]; + var rt = match$1[0]; if (pvd) { - return [ - /* tuple */0, + return /* tuple */[ join(lt, v, d, rt), concat(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat(lt, rt), join(lf, v, d, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -637,14 +619,15 @@ function cons_enum(_m, _e) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -662,18 +645,18 @@ function compare(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_primitive.caml_int_compare(e1[1], e2[1]); + var c = Caml_obj.caml_int_compare(e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -700,10 +683,10 @@ function equal(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - if (e1[1] === e2[1]) { - if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + if (e1[0] === e2[0]) { + if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -730,7 +713,7 @@ function equal(cmp, m1, m2) { function cardinal(param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[4]); + return cardinal(param[0]) + 1 + cardinal(param[3]); } else { return 0; @@ -742,15 +725,13 @@ function bindings_aux(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - [ - /* tuple */0, - param[2], - param[3] + _param = param[0]; + _accu = /* :: */[ + /* tuple */[ + param[1], + param[2] ], - bindings_aux(accu, param[4]) + bindings_aux(accu, param[3]) ]; continue ; diff --git a/jscomp/test/lazy_test.js b/jscomp/test/lazy_test.js index cb7bff1e7a..02fb97c3a8 100644 --- a/jscomp/test/lazy_test.js +++ b/jscomp/test/lazy_test.js @@ -1,25 +1,24 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var CamlinternalLazy = require("../stdlib/camlinternalLazy"); +var Mt = require("./mt"); +var Assert = require("assert"); -var u = [ - 0, - 3 -]; +var u = [3]; -var v = [ - 246, - function () { - u[1] = 32; +var v = { + 0: function () { + u[0] = 32; return /* () */0; - } -]; + }, + length: 1, + tag: 246 +}; function lazy_test() { - var h = u[1]; - var tag = Caml_obj_runtime.caml_obj_tag(v); + var h = u[0]; + var tag = v.tag | 0; if (tag !== 250) { if (tag === 246) { CamlinternalLazy.force_lazy_block(v); @@ -28,15 +27,28 @@ function lazy_test() { ; } } - var g = u[1]; - return [ - /* tuple */0, + var g = u[0]; + return /* tuple */[ h, g ]; } +Mt.from_suites("lazy", /* :: */[ + /* tuple */[ + "simple", + function () { + var prim = lazy_test(/* () */0); + return Assert.deepEqual(prim, /* tuple */[ + 3, + 32 + ]); + } + ], + /* [] */0 + ]); + exports.u = u; exports.v = v; exports.lazy_test = lazy_test; -/* No side effect */ +/* Not a pure module */ diff --git a/jscomp/test/lazy_test.ml b/jscomp/test/lazy_test.ml index c9a74dcc4b..b86ffe22ee 100644 --- a/jscomp/test/lazy_test.ml +++ b/jscomp/test/lazy_test.ml @@ -3,20 +3,20 @@ let u = ref 3 let v = lazy ( u := 32) -let lazy_test (a,b)= +let lazy_test () = let h = !u in let g = (Lazy.force v ; !u) in h,g -(* open Mt *) +open Mt (** this is broken due to [%obj_field] and [%obj_set_field] is translated into [%array_unsafe_get] which does not fit our purpose http://caml.inria.fr/mantis/view.php?id=7020 *) -(* ;; from_suites "lazy" [ *) -(* "simple", (fun _ -> *) -(* assert_equal (a,b) (3, 32) *) -(* ) *) -(* ] *) +;; from_suites "lazy" [ +"simple", (fun _ -> + assert_equal (lazy_test ()) (3, 32) + ) +] diff --git a/jscomp/test/lexer_test.js b/jscomp/test/lexer_test.js index f0fbb9809f..6ee57cf1a2 100644 --- a/jscomp/test/lexer_test.js +++ b/jscomp/test/lexer_test.js @@ -21,8 +21,7 @@ function get_tokens(lex, str) { return List.rev(acc); } else { - _acc = [ - /* :: */0, + _acc = /* :: */[ v, acc ]; @@ -37,15 +36,12 @@ function f(param) { } function from_tokens(lst) { - var l = [ - 0, - lst - ]; + var l = [lst]; var aux = function () { - var match = l[1]; + var match = l[0]; if (match) { - l[1] = match[2]; - return match[1]; + l[0] = match[1]; + return match[0]; } else { throw Caml_builtin_exceptions.End_of_file; @@ -54,46 +50,41 @@ function from_tokens(lst) { return aux; } -var lexer_suites_001 = [ - /* tuple */0, +var lexer_suites_000 = /* tuple */[ "arith_token", function () { - return [ - /* Eq */0, - f("x + 3 + 4 + y"), - [ - /* :: */0, - [ - /* IDENT */1, - "x" - ], - [ - /* :: */0, + return /* Eq */{ + 0: f("x + 3 + 4 + y"), + 1: /* :: */[ + /* IDENT */{ + 0: "x", + length: 1, + tag: 1 + }, + /* :: */[ /* PLUS */0, - [ - /* :: */0, - [ - /* NUMERAL */0, - 3 - ], - [ - /* :: */0, + /* :: */[ + /* NUMERAL */{ + 0: 3, + length: 1, + tag: 0 + }, + /* :: */[ /* PLUS */0, - [ - /* :: */0, - [ - /* NUMERAL */0, - 4 - ], - [ - /* :: */0, + /* :: */[ + /* NUMERAL */{ + 0: 4, + length: 1, + tag: 0 + }, + /* :: */[ /* PLUS */0, - [ - /* :: */0, - [ - /* IDENT */1, - "y" - ], + /* :: */[ + /* IDENT */{ + 0: "y", + length: 1, + tag: 1 + }, /* [] */0 ] ] @@ -101,99 +92,77 @@ var lexer_suites_001 = [ ] ] ] - ] - ]; + ], + length: 2, + tag: 0 + }; } ]; -var lexer_suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var lexer_suites_001 = /* :: */[ + /* tuple */[ "simple token", function () { - return [ - /* Eq */0, - Arith_lexer.lexeme(Lexing.from_string("10")), - [ - /* NUMERAL */0, - 10 - ] - ]; + return /* Eq */{ + 0: Arith_lexer.lexeme(Lexing.from_string("10")), + 1: /* NUMERAL */{ + 0: 10, + length: 1, + tag: 0 + }, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "number_lexer", function () { - var v = [ - 0, - /* [] */0 - ]; + var v = [/* [] */0]; var add = function (t) { - v[1] = [ - /* :: */0, + v[0] = /* :: */[ t, - v[1] + v[0] ]; return /* () */0; }; Number_lexer.token(add, Lexing.from_string("32 + 32 ( ) * / ")); - return [ - /* Eq */0, - List.rev(v[1]), - [ - /* :: */0, + return /* Eq */{ + 0: List.rev(v[0]), + 1: /* :: */[ "number", - [ - /* :: */0, + /* :: */[ "32", - [ - /* :: */0, + /* :: */[ "new line", - [ - /* :: */0, + /* :: */[ "+", - [ - /* :: */0, + /* :: */[ "new line", - [ - /* :: */0, + /* :: */[ "number", - [ - /* :: */0, + /* :: */[ "32", - [ - /* :: */0, + /* :: */[ "new line", - [ - /* :: */0, + /* :: */[ "(", - [ - /* :: */0, + /* :: */[ "new line", - [ - /* :: */0, + /* :: */[ ")", - [ - /* :: */0, + /* :: */[ "new line", - [ - /* :: */0, + /* :: */[ "*", - [ - /* :: */0, + /* :: */[ "new line", - [ - /* :: */0, + /* :: */[ "/", - [ - /* :: */0, + /* :: */[ "new line", - [ - /* :: */0, + /* :: */[ "eof", /* [] */0 ] @@ -212,34 +181,34 @@ var lexer_suites_002 = [ ] ] ] - ] - ]; + ], + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "simple number", function () { - return [ - /* Eq */0, - Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("10"))), - "10." - ]; + return /* Eq */{ + 0: Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("10"))), + 1: "10.", + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "arith", function () { - return [ - /* Eq */0, - Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("x + 3 + 4 + y"))), - "x+3.+4.+y" - ]; + return /* Eq */{ + 0: Arith_syntax.str(Arith_parser.toplevel(Arith_lexer.lexeme, Lexing.from_string("x + 3 + 4 + y"))), + 1: "x+3.+4.+y", + length: 2, + tag: 0 + }; } ], /* [] */0 @@ -248,10 +217,9 @@ var lexer_suites_002 = [ ] ]; -var lexer_suites = [ - /* :: */0, - lexer_suites_001, - lexer_suites_002 +var lexer_suites = /* :: */[ + lexer_suites_000, + lexer_suites_001 ]; Mt.from_pair_suites("lexer_test.ml", lexer_suites); diff --git a/jscomp/test/lexer_test.ml b/jscomp/test/lexer_test.ml index f6e77f98e6..f834fc5819 100644 --- a/jscomp/test/lexer_test.ml +++ b/jscomp/test/lexer_test.ml @@ -55,16 +55,16 @@ let lexer_suites = "/"; "new line"; "eof"])); - "simple number", (fun _ -> + "simple number", (fun _ -> Eq ( Arith_syntax.str ( - Arith_parser.toplevel + Arith_parser.toplevel Arith_lexer.lexeme (Lexing.from_string "10")) , "10." )); - "arith", (fun _ -> - Eq ((Arith_syntax.str - (Arith_parser.toplevel + "arith", (fun _ -> + Eq ((Arith_syntax.str + (Arith_parser.toplevel Arith_lexer.lexeme (Lexing.from_string "x + 3 + 4 + y") ) diff --git a/jscomp/test/lib_js_test.js b/jscomp/test/lib_js_test.js index cde2271602..a7c689ee19 100644 --- a/jscomp/test/lib_js_test.js +++ b/jscomp/test/lib_js_test.js @@ -3,14 +3,11 @@ var Mt = require("./mt"); -console.log(JSON.stringify([ - /* :: */0, +console.log(JSON.stringify(/* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] @@ -19,21 +16,20 @@ console.log(JSON.stringify([ console.log("hey"); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "anything_to_string", function () { - return [ - /* Eq */0, - "3", - "" + 3 - ]; + return /* Eq */{ + 0: "3", + 1: "" + 3, + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/list_test.js b/jscomp/test/list_test.js index 8dcb229063..9c59621458 100644 --- a/jscomp/test/list_test.js +++ b/jscomp/test/list_test.js @@ -2,20 +2,17 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Mt = require("./mt"); -var Caml_primitive = require("../runtime/caml_primitive"); var $$Array = require("../stdlib/array"); var Assert = require("assert"); var List = require("../stdlib/list"); -var list_suites_001 = [ - /* tuple */0, +var list_suites_000 = /* tuple */[ "length", function () { - if (1 === List.length([ - /* :: */0, - [ - /* tuple */0, + if (1 === List.length(/* :: */[ + /* tuple */[ 0, 1, 2, @@ -28,10 +25,8 @@ var list_suites_001 = [ } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "list_test.ml", 5, 3 @@ -41,26 +36,19 @@ var list_suites_001 = [ } ]; -var list_suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var list_suites_001 = /* :: */[ + /* tuple */[ "length2", function () { - if (5 === List.length([ - /* :: */0, + if (5 === List.length(/* :: */[ 0, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, - [ - /* :: */0, + /* :: */[ 4, /* [] */0 ] @@ -72,10 +60,8 @@ var list_suites_002 = [ } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "list_test.ml", 8, 3 @@ -84,10 +70,8 @@ var list_suites_002 = [ } } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "long_length", function () { var v = 100000; @@ -97,42 +81,32 @@ var list_suites_002 = [ return Assert.deepEqual(v, prim); } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "sort", function () { var prim = List.sort(function (x, y) { - return Caml_primitive.caml_int_compare(x, y); - }, [ - /* :: */0, + return Caml_obj.caml_int_compare(x, y); + }, /* :: */[ 4, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ] ] ]); - return Assert.deepEqual(prim, [ - /* :: */0, + return Assert.deepEqual(prim, /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, - [ - /* :: */0, + /* :: */[ 4, /* [] */0 ] @@ -146,10 +120,9 @@ var list_suites_002 = [ ] ]; -var list_suites = [ - /* :: */0, - list_suites_001, - list_suites_002 +var list_suites = /* :: */[ + list_suites_000, + list_suites_001 ]; Mt.from_suites("List_suites", list_suites); diff --git a/jscomp/test/local_exception_test.d.ts b/jscomp/test/local_exception_test.d.ts new file mode 100644 index 0000000000..c0d40b2a4f --- /dev/null +++ b/jscomp/test/local_exception_test.d.ts @@ -0,0 +1,8 @@ +export var v: any ; +export var B: any ; +export var u: any ; +export var D: any ; +export var d: any ; +export var A: any ; +export var x: any ; + diff --git a/jscomp/test/local_exception_test.js b/jscomp/test/local_exception_test.js new file mode 100644 index 0000000000..fe2d6e6470 --- /dev/null +++ b/jscomp/test/local_exception_test.js @@ -0,0 +1,59 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); + +var A = { + 0: "Local_exception_test.A", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; + +var v = [ + A, + 3, + /* true */1 +]; + +var B = { + 0: "Local_exception_test.B", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; + +var D = { + 0: "Local_exception_test.D", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; + +var d = [ + D, + 3 +]; + +var A$1 = { + 0: "Local_exception_test.A", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; + +var x = [ + A$1, + 3 +]; + +var u = B; + +exports.v = v; +exports.B = B; +exports.u = u; +exports.D = D; +exports.d = d; +exports.A = A$1; +exports.x = x; +/* No side effect */ diff --git a/jscomp/test/local_exception_test.ml b/jscomp/test/local_exception_test.ml new file mode 100644 index 0000000000..88b65545f2 --- /dev/null +++ b/jscomp/test/local_exception_test.ml @@ -0,0 +1,17 @@ +exception A of int * bool + +let v = A (3, true) + +exception B + +let u = B + +exception D of int + +let d = D 3 + +exception A of int +(* intentionally overridden , + so that we can not tell the differrence, only by [id]*) + +let x = A 3 diff --git a/jscomp/test/loop_regression_test.js b/jscomp/test/loop_regression_test.js index 204386fdbd..4778c45828 100644 --- a/jscomp/test/loop_regression_test.js +++ b/jscomp/test/loop_regression_test.js @@ -4,43 +4,36 @@ var Mt = require("./mt"); function f() { - var v = [ - 0, - 0 - ]; - var acc = [ - 0, - 0 - ]; + var v = [0]; + var acc = [0]; var n = 10; while(true) { - if (v[1] > n) { - return acc[1]; + if (v[0] > n) { + return acc[0]; } else { - acc[1] += v[1]; - ++ v[1]; + acc[0] += v[0]; + ++ v[0]; continue ; } }; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "sum", function () { - return [ - /* Eq */0, - 55, - f(/* () */0) - ]; + return /* Eq */{ + 0: 55, + 1: f(/* () */0), + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index dcd42acb26..0db4b220f5 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -2,10 +2,10 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Test_inline_map2 = require("./test_inline_map2"); var Mt = require("./mt"); var Test_map_find = require("./test_map_find"); -var Caml_primitive = require("../runtime/caml_primitive"); var Assert = require("assert"); var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); @@ -14,7 +14,7 @@ var Test_inline_map = require("./test_inline_map"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -24,34 +24,34 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -59,7 +59,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -67,19 +66,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -87,31 +85,31 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -121,25 +119,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -148,14 +148,15 @@ function cons_enum(_m, _e) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -173,18 +174,18 @@ function compare(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_primitive.caml_int_compare(e1[1], e2[1]); + var c = Caml_obj.caml_int_compare(e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -211,10 +212,10 @@ function equal(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - if (e1[1] === e2[1]) { - if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + if (e1[0] === e2[0]) { + if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -241,7 +242,7 @@ function equal(cmp, m1, m2) { function cardinal(param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[4]); + return cardinal(param[0]) + 1 + cardinal(param[3]); } else { return 0; @@ -250,7 +251,7 @@ function cardinal(param) { function height$1(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -260,34 +261,34 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal$1(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } else if (lr) { - return create$1(create$1(ll, lv, ld, lr[1]), lr[2], lr[3], create$1(lr[4], x, d, r)); + return create$1(create$1(ll, lv, ld, lr[0]), lr[1], lr[2], create$1(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -295,7 +296,6 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -303,19 +303,18 @@ function bal$1(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create$1(create$1(l, x, d, rl[1]), rl[2], rl[3], create$1(rl[4], rv, rd, rr)); + return create$1(create$1(l, x, d, rl[0]), rl[1], rl[2], create$1(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -323,30 +322,30 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add$1(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -357,25 +356,27 @@ function add$1(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -383,14 +384,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -401,32 +402,25 @@ function find(x, _param) { function of_list(kvs) { return List.fold_left(function (acc, param) { - return add(param[1], param[2], acc); + return add(param[0], param[1], acc); }, /* Empty */0, kvs); } -var int_map_suites_001 = [ - /* tuple */0, +var int_map_suites_000 = /* tuple */[ "add", function () { - var v = of_list([ - /* :: */0, - [ - /* tuple */0, + var v = of_list(/* :: */[ + /* tuple */[ 1, /* "1" */49 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 2, /* "3" */51 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "4" */52 ], @@ -439,10 +433,8 @@ var int_map_suites_001 = [ } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map_test.ml", 16, 4 @@ -452,30 +444,22 @@ var int_map_suites_001 = [ } ]; -var int_map_suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var int_map_suites_001 = /* :: */[ + /* tuple */[ "equal", function () { - var v = of_list([ - /* :: */0, - [ - /* tuple */0, + var v = of_list(/* :: */[ + /* tuple */[ 1, /* "1" */49 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 2, /* "3" */51 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "4" */52 ], @@ -483,24 +467,18 @@ var int_map_suites_002 = [ ] ] ]); - var u = of_list([ - /* :: */0, - [ - /* tuple */0, + var u = of_list(/* :: */[ + /* tuple */[ 2, /* "3" */51 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "4" */52 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 1, /* "1" */49 ], @@ -509,13 +487,11 @@ var int_map_suites_002 = [ ] ]); if (compare(function (prim, prim$1) { - return Caml_primitive.caml_compare(prim, prim$1); + return Caml_obj.caml_compare(prim, prim$1); }, u, v)) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map_test.ml", 21, 4 @@ -527,30 +503,22 @@ var int_map_suites_002 = [ } } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "equal2", function () { - var v = of_list([ - /* :: */0, - [ - /* tuple */0, + var v = of_list(/* :: */[ + /* tuple */[ 1, /* "1" */49 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 2, /* "3" */51 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "4" */52 ], @@ -558,24 +526,18 @@ var int_map_suites_002 = [ ] ] ]); - var u = of_list([ - /* :: */0, - [ - /* tuple */0, + var u = of_list(/* :: */[ + /* tuple */[ 2, /* "3" */51 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "4" */52 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 1, /* "1" */49 ], @@ -590,10 +552,8 @@ var int_map_suites_002 = [ } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map_test.ml", 26, 4 @@ -602,38 +562,28 @@ var int_map_suites_002 = [ } } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "test_inline_map", Test_inline_map.assertions ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "test_inline_map2", Test_inline_map2.assertions1 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "test_inline_map2_1", Test_inline_map2.assertions2 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "test_map_find", Test_map_find.assert_test ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "iteration", function () { var m = /* Empty */0; @@ -658,10 +608,9 @@ var int_map_suites_002 = [ ] ]; -var int_map_suites = [ - /* :: */0, - int_map_suites_001, - int_map_suites_002 +var int_map_suites = /* :: */[ + int_map_suites_000, + int_map_suites_001 ]; Mt.from_suites("map_test", int_map_suites); diff --git a/jscomp/test/module_parameter_test.js b/jscomp/test/module_parameter_test.js index a68671837a..79e0d0f523 100644 --- a/jscomp/test/module_parameter_test.js +++ b/jscomp/test/module_parameter_test.js @@ -9,7 +9,6 @@ function u(v) { } var s = [ - 0, $$String.make, $$String.init, $$String.copy, @@ -37,10 +36,7 @@ var s = [ $$String.compare ]; -var N = [ - 0, - s -]; +var N = [s]; var v0 = 1; @@ -48,38 +44,36 @@ function v(x) { return x.length; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "const", function () { - return [ - /* Eq */0, - 1, - v0 - ]; + return /* Eq */{ + 0: 1, + 1: v0, + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "other", function () { - return [ - /* Eq */0, - 3, - v("abc") - ]; + return /* Eq */{ + 0: 3, + 1: v("abc"), + length: 2, + tag: 0 + }; } ], /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("module_parameter_test.ml", suites); diff --git a/jscomp/test/mt.d.ts b/jscomp/test/mt.d.ts index 64552b8978..568a82a700 100644 --- a/jscomp/test/mt.d.ts +++ b/jscomp/test/mt.d.ts @@ -1,5 +1,4 @@ -export var assert_equal: (prim : any, prim : any) => any ; -export var assert_notequal: (prim : any, prim : any) => any ; export var from_suites: (name : any, suite : any) => any ; export var from_pair_suites: (name : any, suites : any) => any ; +export var assert_equal: (prim : any, prim : any) => any ; diff --git a/jscomp/test/mt.js b/jscomp/test/mt.js index 53c39fce10..a35fb37429 100644 --- a/jscomp/test/mt.js +++ b/jscomp/test/mt.js @@ -1,22 +1,18 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Assert = require("assert"); var Caml_curry = require("../runtime/caml_curry"); +var Assert = require("assert"); var List = require("../stdlib/list"); function assert_equal(prim, prim$1) { return Assert.deepEqual(prim, prim$1); } -function assert_notequal(prim, prim$1) { - return Assert.notDeepEqual(prim, prim$1); -} - function from_suites(name, suite) { return describe(name, function () { return List.iter(function (param) { - return it(param[1], param[2]); + return it(param[0], param[1]); }, suite); }); } @@ -24,22 +20,21 @@ function from_suites(name, suite) { function from_pair_suites(name, suites) { return describe(name, function () { return List.iter(function (param) { - var code = param[2]; - return it(param[1], function () { + var code = param[1]; + return it(param[0], function () { var match = Caml_curry.app1(code, /* () */0); - if (match[0]) { - return Assert.notDeepEqual(match[1], match[2]); + if (match.tag) { + return Assert.notDeepEqual(match[0], match[1]); } else { - return Assert.deepEqual(match[1], match[2]); + return Assert.deepEqual(match[0], match[1]); } }); }, suites); }); } -exports.assert_equal = assert_equal; -exports.assert_notequal = assert_notequal; exports.from_suites = from_suites; exports.from_pair_suites = from_pair_suites; +exports.assert_equal = assert_equal; /* assert Not a pure module */ diff --git a/jscomp/test/mt.mli b/jscomp/test/mt.mli new file mode 100644 index 0000000000..6546df251d --- /dev/null +++ b/jscomp/test/mt.mli @@ -0,0 +1,12 @@ +type _ eq = + | Eq : 'a *'a -> _ eq + | Neq : 'a * 'a -> _ eq + + +type 'a pair_suites = (string * (unit -> 'a eq)) list + +val from_suites : string -> (string * (unit -> unit)) list -> unit +val from_pair_suites : string -> 'a pair_suites -> unit + +val assert_equal : 'a -> 'a -> unit + diff --git a/jscomp/test/number_lexer.js b/jscomp/test/number_lexer.js index 2db4ed1ec9..fb5e7efa41 100644 --- a/jscomp/test/number_lexer.js +++ b/jscomp/test/number_lexer.js @@ -12,8 +12,7 @@ var l = Sys.is_js ? function (prim) { return Pervasives.output_string(Pervasives.stdout, param); }; -var __ocaml_lex_tables = [ - /* record */0, +var __ocaml_lex_tables = /* record */[ "\0\0\xf6\xff\xf7\xff\xf8\xff\xf9\xff\xfa\xff\xfb\xff\xfc\xff:\0\x85\0\xff\xff", "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x02\0\x01\0\xff\xff", "\xff\xff\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\xff\xff\xff\0\0", @@ -36,7 +35,7 @@ function __ocaml_lex_token_rec(l, lexbuf, ___ocaml_lex_state) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); if (__ocaml_lex_state$1 > 9 || __ocaml_lex_state$1 < 0) { - Caml_curry.app1(lexbuf[1], lexbuf); + Caml_curry.app1(lexbuf[0], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; continue ; diff --git a/jscomp/test/obj_magic_test.d.ts b/jscomp/test/obj_magic_test.d.ts new file mode 100644 index 0000000000..a9e75e964a --- /dev/null +++ b/jscomp/test/obj_magic_test.d.ts @@ -0,0 +1,2 @@ +export var empty_backtrace: any ; + diff --git a/jscomp/test/obj_magic_test.js b/jscomp/test/obj_magic_test.js new file mode 100644 index 0000000000..0e4712e362 --- /dev/null +++ b/jscomp/test/obj_magic_test.js @@ -0,0 +1,12 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Obj = require("../stdlib/obj"); + +var empty_backtrace = { + length: 0, + tag: Obj.abstract_tag +}; + +exports.empty_backtrace = empty_backtrace; +/* No side effect */ diff --git a/jscomp/test/obj_magic_test.ml b/jscomp/test/obj_magic_test.ml new file mode 100644 index 0000000000..0876c3123a --- /dev/null +++ b/jscomp/test/obj_magic_test.ml @@ -0,0 +1,2 @@ + +let empty_backtrace = Obj.obj (Obj.new_block Obj.abstract_tag 0) diff --git a/jscomp/test/obj_test.js b/jscomp/test/obj_test.js index 9c09cef345..aad882fca1 100644 --- a/jscomp/test/obj_test.js +++ b/jscomp/test/obj_test.js @@ -7,13 +7,11 @@ var CamlinternalOO = require("../stdlib/camlinternalOO"); var Caml_curry = require("../runtime/caml_curry"); var shared = [ - 0, "hi", "add" ]; var shared$1 = [ - 0, "hi", "hello" ]; @@ -22,9 +20,9 @@ var $$class = CamlinternalOO.create_table(shared$1); var ids = CamlinternalOO.get_method_labels($$class, shared$1); -var hi = ids[1]; +var hi = ids[0]; -var hello = ids[2]; +var hello = ids[1]; CamlinternalOO.set_methods($$class, /* array */[ hi, @@ -33,7 +31,7 @@ CamlinternalOO.set_methods($$class, /* array */[ }, hello, function (self$neg1, z) { - return Caml_curry.app3(self$neg1[1][hi], self$neg1, 10, z); + return Caml_curry.app3(self$neg1[0][hi], self$neg1, 10, z); } ]); @@ -42,20 +40,18 @@ CamlinternalOO.init_class($$class); var vv = CamlinternalOO.create_object_opt(0, $$class); var $$class$1 = CamlinternalOO.create_table([ - 0, "x", "y" ]); var ids$1 = CamlinternalOO.get_method_labels($$class$1, [ - 0, "y", "x" ]); -var y = ids$1[1]; +var y = ids$1[0]; -var x = ids$1[2]; +var x = ids$1[1]; CamlinternalOO.set_methods($$class$1, /* array */[ x, @@ -73,7 +69,6 @@ CamlinternalOO.init_class($$class$1); var v = CamlinternalOO.create_object_opt(0, $$class$1); var $$class$2 = CamlinternalOO.create_table([ - 0, "hi", "id1", "id2", @@ -81,20 +76,19 @@ var $$class$2 = CamlinternalOO.create_table([ ]); var ids$2 = CamlinternalOO.get_method_labels($$class$2, [ - 0, "id2", "id1", "hi", "hello" ]); -var id2 = ids$2[1]; +var id2 = ids$2[0]; -var id1 = ids$2[2]; +var id1 = ids$2[1]; -var hi$1 = ids$2[3]; +var hi$1 = ids$2[2]; -var hello$1 = ids$2[4]; +var hello$1 = ids$2[3]; CamlinternalOO.set_methods($$class$2, /* array */[ hi$1, @@ -119,10 +113,7 @@ CamlinternalOO.init_class($$class$2); var u = CamlinternalOO.create_object_opt(0, $$class$2); -var $$class$3 = CamlinternalOO.create_table([ - 0, - "id" - ]); +var $$class$3 = CamlinternalOO.create_table(["id"]); var id = CamlinternalOO.get_method_label($$class$3, "id"); @@ -134,10 +125,7 @@ CamlinternalOO.init_class($$class$3); var uu = CamlinternalOO.create_object_opt(0, $$class$3); -var $$class$4 = CamlinternalOO.create_table([ - 0, - "add" - ]); +var $$class$4 = CamlinternalOO.create_table(["add"]); var add = CamlinternalOO.get_method_label($$class$4, "add"); @@ -153,9 +141,9 @@ var $$class$5 = CamlinternalOO.create_table(shared); var ids$3 = CamlinternalOO.get_method_labels($$class$5, shared); -var hi$2 = ids$3[1]; +var hi$2 = ids$3[0]; -var add$1 = ids$3[2]; +var add$1 = ids$3[1]; CamlinternalOO.set_methods($$class$5, /* array */[ add$1, @@ -164,7 +152,7 @@ CamlinternalOO.set_methods($$class$5, /* array */[ }, hi$2, function (self$neg6, x) { - return Caml_curry.app3(self$neg6[1][add$1], self$neg6, x, 32); + return Caml_curry.app3(self$neg6[0][add$1], self$neg6, x, 32); } ]); @@ -172,184 +160,172 @@ CamlinternalOO.init_class($$class$5); var vvvv = CamlinternalOO.create_object_opt(0, $$class$5); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "single_obj", function () { - return [ - /* Eq */0, - /* array */[ + return /* Eq */{ + 0: /* int array */[ 3, 32 ], - /* array */[ + 1: /* int array */[ Caml_curry.app1(Caml_oo.caml_get_public_method(v, 120, 1), v), Caml_curry.app1(Caml_oo.caml_get_public_method(v, 121, 2), v) - ] - ]; + ], + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "single_obj_cache", function () { - return [ - /* Eq */0, - /* array */[ + return /* Eq */{ + 0: /* int array */[ 3, 32 ], - /* array */[ + 1: /* int array */[ Caml_curry.app1(Caml_oo.caml_get_public_method(v, 120, 3), v), Caml_curry.app1(Caml_oo.caml_get_public_method(v, 121, 4), v) - ] - ]; + ], + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "self_obj", function () { - return [ - /* Eq */0, - 13, - Caml_curry.app2(Caml_oo.caml_get_public_method(vv, 616641298, 5), vv, 3) - ]; + return /* Eq */{ + 0: 13, + 1: Caml_curry.app2(Caml_oo.caml_get_public_method(vv, 616641298, 5), vv, 3), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "uu_id", function () { - return [ - /* Eq */0, - "uu", - Caml_curry.app1(Caml_oo.caml_get_public_method(uu, 23515, 6), uu) - ]; + return /* Eq */{ + 0: "uu", + 1: Caml_curry.app1(Caml_oo.caml_get_public_method(uu, 23515, 6), uu), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "uu_add", function () { - return [ - /* Eq */0, - Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 7), uuu, 1, 20), - 21 - ]; + return /* Eq */{ + 0: Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 7), uuu, 1, 20), + 1: 21, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "v_add", function () { - return [ - /* Eq */0, - Caml_curry.app3(Caml_oo.caml_get_public_method(vvvv, 4846113, 8), vvvv, 3, 7), - 10 - ]; + return /* Eq */{ + 0: Caml_curry.app3(Caml_oo.caml_get_public_method(vvvv, 4846113, 8), vvvv, 3, 7), + 1: 10, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "u_id1", function () { - return [ - /* Eq */0, - Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243894, 9), u), - 3 - ]; + return /* Eq */{ + 0: Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243894, 9), u), + 1: 3, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "u_id2", function () { - return [ - /* Eq */0, - Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243895, 10), u), - 4 - ]; + return /* Eq */{ + 0: Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243895, 10), u), + 1: 4, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "u hi", function () { - return [ - /* Eq */0, - Caml_curry.app3(Caml_oo.caml_get_public_method(u, 23297, 11), u, 1, 2), - 3 - ]; + return /* Eq */{ + 0: Caml_curry.app3(Caml_oo.caml_get_public_method(u, 23297, 11), u, 1, 2), + 1: 3, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "u hello", function () { - return [ - /* Eq */0, - Caml_curry.app2(Caml_oo.caml_get_public_method(u, 616641298, 12), u, 32), - 32 - ]; + return /* Eq */{ + 0: Caml_curry.app2(Caml_oo.caml_get_public_method(u, 616641298, 12), u, 32), + 1: 32, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "v hi", function () { - return [ - /* Eq */0, - Caml_curry.app2(Caml_oo.caml_get_public_method(vvvv, 23297, 13), vvvv, 31), - 63 - ]; + return /* Eq */{ + 0: Caml_curry.app2(Caml_oo.caml_get_public_method(vvvv, 23297, 13), vvvv, 31), + 1: 63, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "uuu add", function () { - return [ - /* Eq */0, - Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 14), uuu, 3, 4), - 7 - ]; + return /* Eq */{ + 0: Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 14), uuu, 3, 4), + 1: 7, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "v x", function () { - return [ - /* Eq */0, - Caml_curry.app1(Caml_oo.caml_get_public_method(v, 120, 15), v), - 3 - ]; + return /* Eq */{ + 0: Caml_curry.app1(Caml_oo.caml_get_public_method(v, 120, 15), v), + 1: 3, + length: 2, + tag: 0 + }; } ], /* [] */0 @@ -366,10 +342,9 @@ var suites_002 = [ ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("obj_test.ml", suites); diff --git a/jscomp/test/of_string_test.js b/jscomp/test/of_string_test.js index 2ff2d4e4e1..cecd36d677 100644 --- a/jscomp/test/of_string_test.js +++ b/jscomp/test/of_string_test.js @@ -4,52 +4,49 @@ var Pervasives = require("../stdlib/pervasives"); var Mt = require("./mt"); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "string_of_float_1", function () { - return [ - /* Eq */0, - "10.", - Pervasives.string_of_float(10) - ]; + return /* Eq */{ + 0: "10.", + 1: Pervasives.string_of_float(10), + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "string_of_int", function () { - return [ - /* Eq */0, - "10", - "" + 10 - ]; + return /* Eq */{ + 0: "10", + 1: "" + 10, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "valid_float_lexem", function () { - return [ - /* Eq */0, - "10.", - Pervasives.valid_float_lexem("10") - ]; + return /* Eq */{ + 0: "10.", + 1: Pervasives.valid_float_lexem("10"), + length: 2, + tag: 0 + }; } ], /* [] */0 ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("of_string_test.ml", suites); diff --git a/jscomp/test/printf_test.js b/jscomp/test/printf_test.js index d7f4c45150..675575a93a 100644 --- a/jscomp/test/printf_test.js +++ b/jscomp/test/printf_test.js @@ -7,127 +7,138 @@ var Caml_curry = require("../runtime/caml_curry"); var Format = require("../stdlib/format"); function print_pair(fmt, param) { - return Caml_curry.app2(Format.fprintf(fmt, [ - /* Format */0, - [ - /* Char_literal */12, - /* "(" */40, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "," */44, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* ")" */41, - /* End_of_format */0 - ] - ] - ] - ] - ], - "(%d,%d)" - ]), param[1], param[2]); + return Caml_curry.app2(Format.fprintf(fmt, /* Format */{ + 0: /* Char_literal */{ + 0: /* "(" */40, + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "," */44, + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* ")" */41, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 12 + }, + 1: "(%d,%d)", + length: 2, + tag: 0 + }), param[0], param[1]); } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "sprintf_simple", function () { - return [ - /* Eq */0, - "3232", - Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 - ] - ], - "%s%d" - ]), "32", 32) - ]; + return /* Eq */{ + 0: "3232", + 1: Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* String */{ + 0: /* No_padding */0, + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 4 + }, + length: 2, + tag: 2 + }, + 1: "%s%d", + length: 2, + tag: 0 + }), "32", 32), + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "print_asprintf", function () { - return [ - /* Eq */0, - "xx", - Format.asprintf([ - /* Format */0, - [ - /* String_literal */11, - "xx", - /* End_of_format */0 - ], - "xx" - ]) - ]; + return /* Eq */{ + 0: "xx", + 1: Format.asprintf(/* Format */{ + 0: /* String_literal */{ + 0: "xx", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + 1: "xx", + length: 2, + tag: 0 + }), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "print_pair", function () { - return [ - /* Eq */0, - "(1,2)", - Caml_curry.app2(Format.asprintf([ - /* Format */0, - [ - /* Alpha */15, - /* End_of_format */0 - ], - "%a" - ]), print_pair, [ - /* tuple */0, + return /* Eq */{ + 0: "(1,2)", + 1: Caml_curry.app2(Format.asprintf(/* Format */{ + 0: /* Alpha */{ + 0: /* End_of_format */0, + length: 1, + tag: 15 + }, + 1: "%a", + length: 2, + tag: 0 + }), print_pair, /* tuple */[ 1, 2 - ]) - ]; + ]), + length: 2, + tag: 0 + }; } ], /* [] */0 ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; -var v = Format.asprintf([ - /* Format */0, - [ - /* String_literal */11, - "xx", - /* End_of_format */0 - ], - "xx" - ]); +var v = Format.asprintf(/* Format */{ + 0: /* String_literal */{ + 0: "xx", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + 1: "xx", + length: 2, + tag: 0 + }); Mt.from_pair_suites("printf_test.ml", suites); diff --git a/jscomp/test/qcc.js b/jscomp/test/qcc.js index 179beb1085..5bdcd7179e 100644 --- a/jscomp/test/qcc.js +++ b/jscomp/test/qcc.js @@ -4,6 +4,7 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); var Caml_io = require("../runtime/caml_io"); var Bytes = require("../stdlib/bytes"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("../stdlib/pervasives"); var Char = require("../stdlib/char"); var Sys = require("../stdlib/sys"); @@ -14,62 +15,47 @@ var Caml_curry = require("../runtime/caml_curry"); var $$String = require("../stdlib/string"); var List = require("../stdlib/list"); -var dbg = [ - 0, - /* true */1 -]; +var dbg = [/* true */1]; -var inch = [ - 0, - Pervasives.stdin -]; +var inch = [Pervasives.stdin]; function bufferize(f) { - var buf = [ - 0, - /* None */0 - ]; - return [ - /* tuple */0, + var buf = [/* None */0]; + return /* tuple */[ function () { - var match = buf[1]; + var match = buf[0]; if (match) { - buf[1] = /* None */0; - return match[1]; + buf[0] = /* None */0; + return match[0]; } else { return Caml_curry.app1(f, /* () */0); } }, function (x) { - if (buf[1] !== /* None */0) { + if (buf[0] !== /* None */0) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "qcc.ml", 17, 4 ] ]; } - buf[1] = [ - /* Some */0, - x - ]; + buf[0] = /* Some */[x]; return /* () */0; } ]; } var match = bufferize(function () { - return Caml_io.caml_ml_input_char(inch[1]); + return Caml_io.caml_ml_input_char(inch[0]); }); -var ungetch = match[2]; +var ungetch = match[1]; -var getch = match[1]; +var getch = match[0]; function peekch() { var ch = Caml_curry.app1(getch, /* () */0); @@ -79,16 +65,13 @@ function peekch() { var symtab = Caml_array.caml_make_vect(100, ""); -var syms = [ - 0, - 0 -]; +var syms = [0]; function find(s, _n) { while(true) { var n = _n; - if (n >= syms[1]) { - ++ syms[1]; + if (n >= syms[0]) { + ++ syms[0]; return n; } else if (symtab[n] === s) { @@ -102,19 +85,17 @@ function find(s, _n) { }; } -function match_001(s) { +function match_000(s) { var sid = find(s, 0); symtab[sid] = s; return sid; } -function match_002(n) { - if (n >= syms[1]) { +function match_001(n) { + if (n >= syms[0]) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "qcc.ml", 40, 4 @@ -124,25 +105,22 @@ function match_002(n) { return symtab[n]; } -function match_003(f) { - for(var i = 0 ,i_finish = syms[1] - 1; i<= i_finish; ++i){ +function match_002(f) { + for(var i = 0 ,i_finish = syms[0] - 1; i<= i_finish; ++i){ Caml_curry.app2(f, i, symtab[i]); } return /* () */0; } -var symitr = match_003; +var symitr = match_002; -var symstr = match_002; +var symstr = match_001; -var addsym = match_001; +var addsym = match_000; var glo = Bytes.make(4096, /* "\000" */0); -var gpos = [ - 0, - 0 -]; +var gpos = [0]; var base = 4194304; @@ -237,10 +215,7 @@ function skip(_param) { function next() { var match; try { - match = [ - /* Some */0, - skip(/* () */0) - ]; + match = /* Some */[skip(/* () */0)]; } catch (exn){ if (exn === Caml_builtin_exceptions.End_of_file) { @@ -251,7 +226,7 @@ function next() { } } if (match) { - var c = match[1]; + var c = match[0]; var exit = 0; if (c !== 34) { if (c >= 48) { @@ -264,10 +239,11 @@ function next() { var n = _n; var match$1 = peekch(/* () */0); if (match$1 > 57 || match$1 < 48) { - return [ - /* ILit */1, - n - ]; + return /* ILit */{ + 0: n, + length: 1, + tag: 1 + }; } else { _n = 10 * n + Caml_curry.app1(getch, /* () */0) - 48; @@ -285,22 +261,22 @@ function next() { var qt = Caml_curry.app1(getch, /* () */0); if (qt !== /* "'" */39) { throw [ - 0, Caml_builtin_exceptions.Failure, "syntax error" ]; } else { - return [ - /* ILit */1, - ch - ]; + return /* ILit */{ + 0: ch, + length: 1, + tag: 1 + }; } } } else { - var b = gpos[1]; - var _e = gpos[1]; + var b = gpos[0]; + var _e = gpos[0]; while(true) { var e = _e; var match$2 = peekch(/* () */0); @@ -312,12 +288,13 @@ function next() { } else { Caml_curry.app1(getch, /* () */0); - gpos[1] = e + 8 & -8; - return [ - /* SLit */2, - b + textoff + base, - Bytes.to_string(Bytes.sub(glo, b, e - b)) - ]; + gpos[0] = e + 8 & -8; + return /* SLit */{ + 0: b + textoff + base, + 1: Bytes.to_string(Bytes.sub(glo, b, e - b)), + length: 2, + tag: 2 + }; } }; } @@ -336,44 +313,35 @@ function next() { } else { - return [ - /* Sym */3, - Caml_curry.app1(addsym, Bytes.to_string(Bytes.sub(s, 0, n$1 + 1))) - ]; + return /* Sym */{ + 0: Caml_curry.app1(addsym, Bytes.to_string(Bytes.sub(s, 0, n$1 + 1))), + length: 1, + tag: 3 + }; } }; } else { var ch$2 = c; - var _param = [ - /* :: */0, + var _param = /* :: */[ "++", - [ - /* :: */0, + /* :: */[ "--", - [ - /* :: */0, + /* :: */[ "&&", - [ - /* :: */0, + /* :: */[ "||", - [ - /* :: */0, + /* :: */[ "==", - [ - /* :: */0, + /* :: */[ "<=", - [ - /* :: */0, + /* :: */[ ">=", - [ - /* :: */0, + /* :: */[ "!=", - [ - /* :: */0, + /* :: */[ ">>", - [ - /* :: */0, + /* :: */[ "<<", /* [] */0 ] @@ -389,25 +357,27 @@ function next() { while(true) { var param = _param; if (param) { - var lop = param[1]; + var lop = param[0]; if (lop.charCodeAt(0) === ch$2 && lop.charCodeAt(1) === peekch(/* () */0)) { Caml_curry.app1(getch, /* () */0); - return [ - /* Op */0, - lop - ]; + return /* Op */{ + 0: lop, + length: 1, + tag: 0 + }; } else { - _param = param[2]; + _param = param[1]; continue ; } } else { - return [ - /* Op */0, - $$String.make(1, ch$2) - ]; + return /* Op */{ + 0: $$String.make(1, ch$2), + length: 1, + tag: 0 + }; } }; } @@ -415,37 +385,35 @@ function next() { } else { - return [ - /* Op */0, - "EOF!" - ]; + return /* Op */{ + 0: "EOF!", + length: 1, + tag: 0 + }; } } var match$1 = bufferize(next); -var unnext = match$1[2]; +var unnext = match$1[1]; -var next$1 = match$1[1]; +var next$1 = match$1[0]; function nextis(t) { var nt = Caml_curry.app1(next$1, /* () */0); Caml_curry.app1(unnext, nt); - return Caml_primitive.caml_equal(t, nt); + return Caml_obj.caml_equal(t, nt); } var obuf = Bytes.make(1048576, /* "\000" */0); -var opos = [ - 0, - 0 -]; +var opos = [0]; function out(x) { if (x !== 0) { out(x / 256 | 0); - obuf[opos[1]] = Char.chr(x & 255); - return ++ opos[1]; + obuf[opos[0]] = Char.chr(x & 255); + return ++ opos[0]; } else { return 0; @@ -455,8 +423,8 @@ function out(x) { function le(n, x) { for(var i = 0 ,i_finish = (n / 8 | 0) - 1; i<= i_finish; ++i){ var $$byte = (x >>> i * 8) & 255; - obuf[opos[1]] = Char.chr($$byte); - ++ opos[1]; + obuf[opos[0]] = Char.chr($$byte); + ++ opos[0]; } return /* () */0; } @@ -468,10 +436,8 @@ function get32(l) { function patch(rel, loc, n) { if (n >= 4294967296) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "qcc.ml", 157, 2 @@ -479,54 +445,62 @@ function patch(rel, loc, n) { ]; } if (loc !== 0) { - var i = opos[1]; + var i = opos[0]; var loc$prime = get32(loc); var x = rel ? n - (loc + 4) : n; - if (dbg[1]) { - Caml_curry.app3(Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "patching at ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - " to ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - " (n=", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ")\n", - /* End_of_format */0 - ] - ] - ] - ] - ] - ] - ], - "patching at %d to %d (n=%d)\n" - ]), loc, x, n); + if (dbg[0]) { + Caml_curry.app3(Printf.eprintf(/* Format */{ + 0: /* String_literal */{ + 0: "patching at ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: " to ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: " (n=", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ")\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "patching at %d to %d (n=%d)\n", + length: 2, + tag: 0 + }), loc, x, n); } - opos[1] = loc; + opos[0] = loc; le(32, x); patch(rel, loc$prime, n); - opos[1] = i; + opos[0] = i; return /* () */0; } else { @@ -547,18 +521,15 @@ function cmp(n) { function test(n, l) { out(4752832); out(3972 + n); - var loc = opos[1]; + var loc = opos[0]; le(32, l); return loc; } -var align = [ - 0, - 0 -]; +var align = [0]; function push(r) { - ++ align[1]; + ++ align[0]; if (r < 8) { return out(80 + r); } @@ -568,7 +539,7 @@ function push(r) { } function pop(r) { - -- align[1]; + -- align[0]; if (r < 8) { return out(88 + r); } @@ -577,26 +548,23 @@ function pop(r) { } } -var lval = [ - 0, - [ - /* tuple */0, - [ - /* Mov */0, - 0 - ], +var lval = [/* tuple */[ + /* Mov */{ + 0: 0, + length: 1, + tag: 0 + }, /* Int */0 - ] -]; + ]]; function patchlval() { - var match = lval[1][1]; - if (match[0]) { - opos[1] -= match[1]; + var match = lval[0][0]; + if (match.tag) { + opos[0] -= match[0]; return /* () */0; } else { - obuf[opos[1] - match[1]] = /* "\141" */141; + obuf[opos[0] - match[0]] = /* "\141" */141; return /* () */0; } } @@ -605,12 +573,12 @@ function read(param) { if (param !== 0) { out(4722614); le(8, 0); - lval[1] = [ - /* tuple */0, - [ - /* Del */1, - 4 - ], + lval[0] = /* tuple */[ + /* Del */{ + 0: 4, + length: 1, + tag: 1 + }, /* Chr */1 ]; return /* () */0; @@ -618,147 +586,110 @@ function read(param) { else { out(18571); le(8, 0); - lval[1] = [ - /* tuple */0, - [ - /* Del */1, - 3 - ], + lval[0] = /* tuple */[ + /* Del */{ + 0: 3, + length: 1, + tag: 1 + }, /* Int */0 ]; return /* () */0; } } -var globs = Caml_array.caml_make_vect(100, [ - /* record */0, +var globs = Caml_array.caml_make_vect(100, /* record */[ 0, -1 ]); -var lvls = [ - /* :: */0, - [ - /* tuple */0, +var lvls = /* :: */[ + /* tuple */[ "*", 0 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "/", 0 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "%", 0 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "+", 1 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "-", 1 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "<<", 2 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ ">>", 2 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "<", 3 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "<=", 3 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ ">", 3 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ ">=", 3 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "==", 4 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "!=", 4 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "&", 5 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "^", 6 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "|", 7 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "&&", 8 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "||", 9 ], @@ -782,237 +713,203 @@ var lvls = [ ] ]; -var inss = [ - /* :: */0, - [ - /* tuple */0, +var inss = /* :: */[ + /* tuple */[ "*", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 1208987585, /* [] */0 - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "/", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 18577, - [ - /* :: */0, + /* :: */[ 18585, - [ - /* :: */0, + /* :: */[ 4782073, /* [] */0 ] ] - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "%", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 18577, - [ - /* :: */0, + /* :: */[ 18585, - [ - /* :: */0, + /* :: */[ 4782073, - [ - /* :: */0, + /* :: */[ 18578, /* [] */0 ] ] ] - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "+", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 4719048, /* [] */0 - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "-", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 18577, - [ - /* :: */0, + /* :: */[ 4729288, /* [] */0 ] - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "<<", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 18577, - [ - /* :: */0, + /* :: */[ 4772832, /* [] */0 ] - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ ">>", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 18577, - [ - /* :: */0, + /* :: */[ 4772856, /* [] */0 ] - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "<", - [ - /* Cmp */1, - 10 - ] + /* Cmp */{ + 0: 10, + length: 1, + tag: 1 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "<=", - [ - /* Cmp */1, - 12 - ] + /* Cmp */{ + 0: 12, + length: 1, + tag: 1 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ ">", - [ - /* Cmp */1, - 13 - ] + /* Cmp */{ + 0: 13, + length: 1, + tag: 1 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ ">=", - [ - /* Cmp */1, - 11 - ] + /* Cmp */{ + 0: 11, + length: 1, + tag: 1 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "==", - [ - /* Cmp */1, - 2 - ] + /* Cmp */{ + 0: 2, + length: 1, + tag: 1 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "!=", - [ - /* Cmp */1, - 3 - ] + /* Cmp */{ + 0: 3, + length: 1, + tag: 1 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "&", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 4727240, /* [] */0 - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "^", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 4731336, /* [] */0 - ] - ] + ], + length: 1, + tag: 0 + } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "|", - [ - /* Bin */0, - [ - /* :: */0, + /* Bin */{ + 0: /* :: */[ 4721096, /* [] */0 - ] - ] + ], + length: 1, + tag: 0 + } ], /* [] */0 ] @@ -1032,61 +929,53 @@ var inss = [ ] ]; -var tokint_001 = Caml_curry.app1(addsym, "int"); - -var tokint = [ - /* Sym */3, - tokint_001 -]; - -var tokchar_001 = Caml_curry.app1(addsym, "char"); - -var tokchar = [ - /* Sym */3, - tokchar_001 -]; - -var tokret_001 = Caml_curry.app1(addsym, "return"); - -var tokret = [ - /* Sym */3, - tokret_001 -]; - -var tokif_001 = Caml_curry.app1(addsym, "if"); - -var tokif = [ - /* Sym */3, - tokif_001 -]; - -var tokelse_001 = Caml_curry.app1(addsym, "else"); - -var tokelse = [ - /* Sym */3, - tokelse_001 -]; - -var tokwhile_001 = Caml_curry.app1(addsym, "while"); - -var tokwhile = [ - /* Sym */3, - tokwhile_001 -]; - -var tokfor_001 = Caml_curry.app1(addsym, "for"); - -var tokfor = [ - /* Sym */3, - tokfor_001 -]; - -var tokbreak_001 = Caml_curry.app1(addsym, "break"); - -var tokbreak = [ - /* Sym */3, - tokbreak_001 -]; +var tokint = /* Sym */{ + 0: Caml_curry.app1(addsym, "int"), + length: 1, + tag: 3 +}; + +var tokchar = /* Sym */{ + 0: Caml_curry.app1(addsym, "char"), + length: 1, + tag: 3 +}; + +var tokret = /* Sym */{ + 0: Caml_curry.app1(addsym, "return"), + length: 1, + tag: 3 +}; + +var tokif = /* Sym */{ + 0: Caml_curry.app1(addsym, "if"), + length: 1, + tag: 3 +}; + +var tokelse = /* Sym */{ + 0: Caml_curry.app1(addsym, "else"), + length: 1, + tag: 3 +}; + +var tokwhile = /* Sym */{ + 0: Caml_curry.app1(addsym, "while"), + length: 1, + tag: 3 +}; + +var tokfor = /* Sym */{ + 0: Caml_curry.app1(addsym, "for"), + length: 1, + tag: 3 +}; + +var tokbreak = /* Sym */{ + 0: Caml_curry.app1(addsym, "break"), + length: 1, + tag: 3 +}; function binary(stk, lvl) { if (lvl === -1) { @@ -1105,11 +994,11 @@ function binary(stk, lvl) { while(true) { var loc = _loc; var t = Caml_curry.app1(next$1, /* () */0); - if (t[0]) { + if (t.tag) { Caml_curry.app1(unnext, t); return loc; } - else if (lvlof(t[1]) === lvl) { + else if (lvlof(t[0]) === lvl) { var loc$prime = test(lvl - 8, loc); binary(stk, lvl - 1); _loc = loc$prime; @@ -1127,22 +1016,22 @@ function binary(stk, lvl) { var _param = /* () */0; while(true) { var t = Caml_curry.app1(next$1, /* () */0); - if (t[0]) { + if (t.tag) { return Caml_curry.app1(unnext, t); } else { - var o = t[1]; + var o = t[0]; if (lvlof(o) === lvl) { push(0); binary(stk, lvl - 1); pop(1); var match = List.assoc(o, inss); - if (match[0]) { + if (match.tag) { out(4733377); - cmp(match[1]); + cmp(match[0]); } else { - List.iter(out, match[1]); + List.iter(out, match[0]); } _param = /* () */0; continue ; @@ -1156,16 +1045,16 @@ function binary(stk, lvl) { } else { var loc = foldtst(0); - return patch(/* true */1, loc, opos[1]); + return patch(/* true */1, loc, opos[0]); } } } function unary(stk) { var match = Caml_curry.app1(next$1, /* () */0); - switch (match[0]) { + switch (match.tag | 0) { case 0 : - var o = match[1]; + var o = match[0]; switch (o) { case "&" : unary(stk); @@ -1178,65 +1067,54 @@ function unary(stk) { Caml_curry.app1(next$1, /* () */0); var t = Caml_curry.app1(next$1, /* () */0); var match$1; - if (Caml_primitive.caml_equal(t, tokint)) { - match$1 = Caml_primitive.caml_equal(Caml_curry.app1(next$1, /* () */0), [ - /* Op */0, - "*" - ]) ? [ - /* tuple */0, + if (Caml_obj.caml_equal(t, tokint)) { + match$1 = Caml_obj.caml_equal(Caml_curry.app1(next$1, /* () */0), /* Op */{ + 0: "*", + length: 1, + tag: 0 + }) ? /* tuple */[ /* Int */0, 1 - ] : [ - /* tuple */0, + ] : /* tuple */[ /* Int */0, 5 ]; } - else if (Caml_primitive.caml_equal(t, tokchar)) { - match$1 = [ - /* tuple */0, + else if (Caml_obj.caml_equal(t, tokchar)) { + match$1 = /* tuple */[ /* Chr */1, 2 ]; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "[cast] expected" ]; } - for(var k = 1 ,k_finish = match$1[2]; k<= k_finish; ++k){ + for(var k = 1 ,k_finish = match$1[1]; k<= k_finish; ++k){ Caml_curry.app1(next$1, /* () */0); } unary(stk); - return read(match$1[1]); + return read(match$1[0]); default: - var unops = [ - /* :: */0, - [ - /* tuple */0, + var unops = /* :: */[ + /* tuple */[ "+", 0 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "-", 4782040 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "~", 4782032 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "!", 4752832 ], @@ -1247,21 +1125,23 @@ function unary(stk) { ]; unary(stk); if (!List.mem_assoc(o, unops)) { - var s = Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "unknown operator ", - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "unknown operator %s" - ]), o); + var s = Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "unknown operator ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "unknown operator %s", + length: 2, + tag: 0 + }), o); throw [ - 0, Caml_builtin_exceptions.Failure, s ]; @@ -1276,20 +1156,18 @@ function unary(stk) { } break; case 1 : - return load(0, match[1]); + return load(0, match[0]); case 2 : out(18616); - return le(64, match[1]); + return le(64, match[0]); case 3 : - var i = match[1]; + var i = match[0]; if (List.mem_assoc(i, stk)) { var l = List.assoc(i, stk); if (l <= -256) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "qcc.ml", 295, 6 @@ -1298,24 +1176,23 @@ function unary(stk) { } out(4754245); out(l & 255); - lval[1] = [ - /* tuple */0, - [ - /* Mov */0, - 3 - ], + lval[0] = /* tuple */[ + /* Mov */{ + 0: 3, + length: 1, + tag: 0 + }, /* Int */0 ]; } else { out(18616); var g = globs[i]; - var loc = opos[1]; - le(64, g[1]); - globs[i] = [ - /* record */0, + var loc = opos[0]; + le(64, g[0]); + globs[i] = /* record */[ loc, - g[2] + g[1] ]; read(/* Int */0); } @@ -1326,11 +1203,11 @@ function unary(stk) { function postfix(stk) { var t = Caml_curry.app1(next$1, /* () */0); - if (t[0]) { + if (t.tag) { return Caml_curry.app1(unnext, t); } else { - var op = t[1]; + var op = t[0]; var exit = 0; switch (op) { case "(" : @@ -1338,25 +1215,26 @@ function postfix(stk) { while(true) { var rl = _rl; var l = _l; - if (nextis([ - /* Op */0, - ")" - ])) { + if (nextis(/* Op */{ + 0: ")", + length: 1, + tag: 0 + })) { Caml_curry.app1(next$1, /* () */0); return List.iter(pop, l); } else { expr(stk); push(0); - if (nextis([ - /* Op */0, - "," - ])) { + if (nextis(/* Op */{ + 0: ",", + length: 1, + tag: 0 + })) { Caml_curry.app1(next$1, /* () */0); } _rl = List.tl(rl); - _l = [ - /* :: */0, + _l = /* :: */[ List.hd(rl), l ]; @@ -1367,23 +1245,17 @@ function postfix(stk) { }; patchlval(/* () */0); push(0); - emitargs(/* [] */0, [ - /* :: */0, + emitargs(/* [] */0, /* :: */[ 7, - [ - /* :: */0, + /* :: */[ 6, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 8, - [ - /* :: */0, + /* :: */[ 9, /* [] */0 ] @@ -1393,11 +1265,11 @@ function postfix(stk) { ] ]); pop(0); - if (align[1] % 2 !== 0) { + if (align[0] % 2 !== 0) { out(1216605192); } out(65488); - if (align[1] % 2 !== 0) { + if (align[0] % 2 !== 0) { return out(1216594952); } else { @@ -1413,50 +1285,37 @@ function postfix(stk) { if (exit === 1) { patchlval(/* () */0); out(4753857); - read(lval[1][2]); - return out(List.assoc([ - /* tuple */0, + read(lval[0][1]); + return out(List.assoc(/* tuple */[ op, - lval[1][2] - ], [ - /* :: */0, - [ - /* tuple */0, - [ - /* tuple */0, + lval[0][1] + ], /* :: */[ + /* tuple */[ + /* tuple */[ "++", /* Int */0 ], 4783873 ], - [ - /* :: */0, - [ - /* tuple */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ + /* tuple */[ "--", /* Int */0 ], 4783881 ], - [ - /* :: */0, - [ - /* tuple */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ + /* tuple */[ "++", /* Chr */1 ], 65025 ], - [ - /* :: */0, - [ - /* tuple */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ + /* tuple */[ "--", /* Chr */1 ], @@ -1477,12 +1336,12 @@ function expr(stk) { var _param = /* () */0; while(true) { var t = Caml_curry.app1(next$1, /* () */0); - if (t[0]) { + if (t.tag) { return Caml_curry.app1(unnext, t); } - else if (t[1] === "=") { + else if (t[0] === "=") { patchlval(/* () */0); - var ty = lval[1][2]; + var ty = lval[0][1]; push(0); expr(stk); pop(1); @@ -1507,68 +1366,66 @@ function decl(g, _n, _stk) { var stk = _stk; var n = _n; var t = Caml_curry.app1(next$1, /* () */0); - if (Caml_primitive.caml_equal(t, tokint)) { - var top = stk ? stk[1][2] : 0; + if (Caml_obj.caml_equal(t, tokint)) { + var top = stk ? stk[0][1] : 0; var vars = (function(top){ return function (_n, _stk) { while(true) { var stk = _stk; var n = _n; - while(nextis([ - /* Op */0, - "*" - ])) { + while(nextis(/* Op */{ + 0: "*", + length: 1, + tag: 0 + })) { Caml_curry.app1(next$1, /* () */0); }; - if (nextis([ - /* Op */0, - ";" - ])) { - return [ - /* tuple */0, + if (nextis(/* Op */{ + 0: ";", + length: 1, + tag: 0 + })) { + return /* tuple */[ n, stk ]; } else { var match = Caml_curry.app1(next$1, /* () */0); - if (match[0] === 3) { - var s = match[1]; + if (match.tag === 3) { + var s = match[0]; var n$prime = n + 1; var stk$prime; if (g) { var glo = globs[s]; - if (glo[2] >= 0) { + if (glo[1] >= 0) { throw [ - 0, Caml_builtin_exceptions.Failure, "symbol defined twice" ]; } - var va = gpos[1] + textoff + base; - globs[s] = [ - /* record */0, - glo[1], + var va = gpos[0] + textoff + base; + globs[s] = /* record */[ + glo[0], va ]; - gpos[1] += 8; + gpos[0] += 8; stk$prime = stk; } else { - stk$prime = [ - /* :: */0, - [ - /* tuple */0, + stk$prime = /* :: */[ + /* tuple */[ s, top - 8 * n$prime ], stk ]; } - if (nextis([ - /* Op */0, - "," - ])) { + if (nextis(/* Op */{ + 0: ",", + length: 1, + tag: 0 + })) { Caml_curry.app1(next$1, /* () */0); _stk = stk$prime; _n = n$prime; @@ -1576,8 +1433,7 @@ function decl(g, _n, _stk) { } else { - return [ - /* tuple */0, + return /* tuple */[ n$prime, stk$prime ]; @@ -1585,7 +1441,6 @@ function decl(g, _n, _stk) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "[var] expected in [decl]" ]; @@ -1596,29 +1451,33 @@ function decl(g, _n, _stk) { }(top)); var match = vars(0, stk); Caml_curry.app1(next$1, /* () */0); - if (dbg[1]) { - Caml_curry.app1(Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "end of decl (", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - " vars)\n", - /* End_of_format */0 - ] - ] - ], - "end of decl (%d vars)\n" - ]), n); + if (dbg[0]) { + Caml_curry.app1(Printf.eprintf(/* Format */{ + 0: /* String_literal */{ + 0: "end of decl (", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: " vars)\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "end of decl (%d vars)\n", + length: 2, + tag: 0 + }), n); } - _stk = match[2]; - _n = n + match[1]; + _stk = match[1]; + _n = n + match[0]; continue ; } @@ -1627,10 +1486,8 @@ function decl(g, _n, _stk) { if (!g && n !== 0) { if (n * 8 >= 256) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "qcc.ml", 436, 6 @@ -1639,13 +1496,12 @@ function decl(g, _n, _stk) { } out(4752364); out(n * 8); - align[1] += n; + align[0] += n; } - if (dbg[1] && !g) { + if (dbg[0] && !g) { console.error("end of blk decls"); } - return [ - /* tuple */0, + return /* tuple */[ n, stk ]; @@ -1653,10 +1509,7 @@ function decl(g, _n, _stk) { }; } -var retl = [ - 0, - 0 -]; +var retl = [0]; function stmt(brk, stk) { var pexpr = function (stk) { @@ -1666,7 +1519,7 @@ function stmt(brk, stk) { }; var t = Caml_curry.app1(next$1, /* () */0); var exit = 0; - if (Caml_primitive.caml_equal(t, tokif)) { + if (Caml_obj.caml_equal(t, tokif)) { pexpr(stk); var loc = test(0, 0); stmt(brk, stk); @@ -1674,104 +1527,99 @@ function stmt(brk, stk) { if (nextis(tokelse)) { Caml_curry.app1(next$1, /* () */0); out(233); - var l = opos[1]; + var l = opos[0]; le(32, 0); - patch(/* true */1, loc, opos[1]); + patch(/* true */1, loc, opos[0]); stmt(brk, stk); loc$1 = l; } else { loc$1 = loc; } - return patch(/* true */1, loc$1, opos[1]); + return patch(/* true */1, loc$1, opos[0]); } - else if (Caml_primitive.caml_equal(t, tokwhile) || Caml_primitive.caml_equal(t, tokfor)) { - var match_001 = [ - 0, - 0 - ]; - var match_002 = align[1]; - var bl = match_001; + else if (Caml_obj.caml_equal(t, tokwhile) || Caml_obj.caml_equal(t, tokfor)) { + var match_000 = [0]; + var match_001 = align[0]; + var bl = match_000; var match; - if (Caml_primitive.caml_equal(t, tokwhile)) { - var loc$2 = opos[1]; + if (Caml_obj.caml_equal(t, tokwhile)) { + var loc$2 = opos[0]; pexpr(stk); - bl[1] = test(0, 0); - match = [ - /* tuple */0, + bl[0] = test(0, 0); + match = /* tuple */[ 0, loc$2 ]; } else { Caml_curry.app1(next$1, /* () */0); - if (!nextis([ - /* Op */0, - ";" - ])) { + if (!nextis(/* Op */{ + 0: ";", + length: 1, + tag: 0 + })) { expr(stk); } Caml_curry.app1(next$1, /* () */0); - var top = opos[1]; - if (nextis([ - /* Op */0, - ";" - ])) { - bl[1] = 0; + var top = opos[0]; + if (nextis(/* Op */{ + 0: ";", + length: 1, + tag: 0 + })) { + bl[0] = 0; } else { expr(stk); - bl[1] = test(0, 0); + bl[0] = test(0, 0); } Caml_curry.app1(next$1, /* () */0); out(233); - var bdy = opos[1]; + var bdy = opos[0]; le(32, 0); - var itr = opos[1]; + var itr = opos[0]; expr(stk); Caml_curry.app1(next$1, /* () */0); out(233); - le(32, top - opos[1] - 4); - match = [ - /* tuple */0, + le(32, top - opos[0] - 4); + match = /* tuple */[ bdy, itr ]; } - patch(/* true */1, match[1], opos[1]); - stmt([ - /* tuple */0, + patch(/* true */1, match[0], opos[0]); + stmt(/* tuple */[ bl, - match_002 + match_001 ], stk); out(233); - le(32, match[2] - opos[1] - 4); - return patch(/* true */1, bl[1], opos[1]); + le(32, match[1] - opos[0] - 4); + return patch(/* true */1, bl[0], opos[0]); } - else if (Caml_primitive.caml_equal(t, tokret)) { - if (!nextis([ - /* Op */0, - ";" - ])) { + else if (Caml_obj.caml_equal(t, tokret)) { + if (!nextis(/* Op */{ + 0: ";", + length: 1, + tag: 0 + })) { expr(stk); } Caml_curry.app1(next$1, /* () */0); out(233); - var loc$3 = opos[1]; - le(32, retl[1]); - retl[1] = loc$3; + var loc$3 = opos[0]; + le(32, retl[0]); + retl[0] = loc$3; return /* () */0; } - else if (Caml_primitive.caml_equal(t, tokbreak)) { + else if (Caml_obj.caml_equal(t, tokbreak)) { Caml_curry.app1(next$1, /* () */0); - var brkl = brk[1]; - var n = align[1] - brk[2]; + var brkl = brk[0]; + var n = align[0] - brk[1]; if (n < 0) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "qcc.ml", 515, 4 @@ -1783,16 +1631,16 @@ function stmt(brk, stk) { out(n * 8); } out(233); - var loc$4 = opos[1]; - le(32, brkl[1]); - brkl[1] = loc$4; + var loc$4 = opos[0]; + le(32, brkl[0]); + brkl[0] = loc$4; return /* () */0; } - else if (t[0]) { + else if (t.tag) { exit = 1; } else { - switch (t[1]) { + switch (t[0]) { case ";" : return /* () */0; case "{" : @@ -1811,19 +1659,20 @@ function stmt(brk, stk) { function block(brk, stk) { var match = decl(/* false */0, 0, stk); - var stk$prime = match[2]; - var n = match[1]; - while(!nextis([ - /* Op */0, - "}" - ])) { + var stk$prime = match[1]; + var n = match[0]; + while(!nextis(/* Op */{ + 0: "}", + length: 1, + tag: 0 + })) { stmt(brk, stk$prime); }; Caml_curry.app1(next$1, /* () */0); if (n !== 0) { out(4752324); out(n * 8); - align[1] -= n; + align[0] -= n; return /* () */0; } else { @@ -1833,10 +1682,11 @@ function block(brk, stk) { function top(_param) { while(true) { - if (nextis([ - /* Op */0, - "EOF!" - ])) { + if (nextis(/* Op */{ + 0: "EOF!", + length: 1, + tag: 0 + })) { return 0; } else if (nextis(tokint)) { @@ -1847,20 +1697,18 @@ function top(_param) { } else { var match = Caml_curry.app1(next$1, /* () */0); - if (match[0] === 3) { - var f = match[1]; + if (match.tag === 3) { + var f = match[0]; var g = globs[f]; - if (g[2] >= 0) { + if (g[1] >= 0) { throw [ - 0, Caml_builtin_exceptions.Failure, "symbol defined twice" ]; } - globs[f] = [ - /* record */0, - g[1], - opos[1] + globs[f] = /* record */[ + g[0], + opos[0] ]; var emitargs = function (_regs, _n, _stk) { while(true) { @@ -1868,14 +1716,13 @@ function top(_param) { var n = _n; var regs = _regs; var match = Caml_curry.app1(next$1, /* () */0); - switch (match[0]) { + switch (match.tag | 0) { case 0 : - if (match[1] === ")") { + if (match[0] === ")") { return stk; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "[var] or ) expected" ]; @@ -1884,27 +1731,25 @@ function top(_param) { case 1 : case 2 : throw [ - 0, Caml_builtin_exceptions.Failure, "[var] or ) expected" ]; case 3 : var r = List.hd(regs); push(r); - if (nextis([ - /* Op */0, - "," - ])) { + if (nextis(/* Op */{ + 0: ",", + length: 1, + tag: 0 + })) { Caml_curry.app1(next$1, /* () */0); } - var stk$prime_001 = [ - /* tuple */0, - match[1], + var stk$prime_000 = /* tuple */[ + match[0], -n * 8 ]; - var stk$prime = [ - /* :: */0, - stk$prime_001, + var stk$prime = /* :: */[ + stk$prime_000, stk ]; _stk = stk$prime; @@ -1916,26 +1761,20 @@ function top(_param) { }; }; Caml_curry.app1(next$1, /* () */0); - align[1] = 0; + align[0] = 0; out(85); out(4753893); - var stk = emitargs([ - /* :: */0, + var stk = emitargs(/* :: */[ 7, - [ - /* :: */0, + /* :: */[ 6, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 8, - [ - /* :: */0, + /* :: */[ 9, /* [] */0 ] @@ -1944,41 +1783,42 @@ function top(_param) { ] ] ], 1, /* [] */0); - while(Caml_primitive.caml_notequal(Caml_curry.app1(next$1, /* () */0), [ - /* Op */0, - "{" - ])) { + while(Caml_obj.caml_notequal(Caml_curry.app1(next$1, /* () */0), /* Op */{ + 0: "{", + length: 1, + tag: 0 + })) { }; - retl[1] = 0; - block([ - /* tuple */0, - [ - 0, - 0 - ], + retl[0] = 0; + block(/* tuple */[ + [0], 0 ], stk); - patch(/* true */1, retl[1], opos[1]); + patch(/* true */1, retl[0], opos[0]); out(51651); - if (dbg[1]) { - Caml_curry.app1(Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "done with function ", - [ - /* String */2, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "done with function %s\n" - ]), Caml_curry.app1(symstr, f)); + if (dbg[0]) { + Caml_curry.app1(Printf.eprintf(/* Format */{ + 0: /* String_literal */{ + 0: "done with function ", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "done with function %s\n", + length: 2, + tag: 0 + }), Caml_curry.app1(symstr, f)); } _param = /* () */0; continue ; @@ -1986,7 +1826,6 @@ function top(_param) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "[decl] or [fun] expected" ]; @@ -1995,50 +1834,35 @@ function top(_param) { }; } -var elfhdr = Bytes.of_string($$String.concat("", [ - /* :: */0, +var elfhdr = Bytes.of_string($$String.concat("", /* :: */[ "\x7fELF\x02\x01\x01\0", - [ - /* :: */0, + /* :: */[ "\0\0\0\0\0\0\0\0", - [ - /* :: */0, + /* :: */[ "\x02\0", - [ - /* :: */0, + /* :: */[ ">\0", - [ - /* :: */0, + /* :: */[ "\x01\0\0\0", - [ - /* :: */0, + /* :: */[ "\0\0\0\0\0\0\0\0", - [ - /* :: */0, + /* :: */[ "@\0\0\0\0\0\0\0", - [ - /* :: */0, + /* :: */[ "\0\0\0\0\0\0\0\0", - [ - /* :: */0, + /* :: */[ "\0\0\0\0", - [ - /* :: */0, + /* :: */[ "@\0", - [ - /* :: */0, + /* :: */[ "8\0", - [ - /* :: */0, + /* :: */[ "\x03\0", - [ - /* :: */0, + /* :: */[ "@\0", - [ - /* :: */0, + /* :: */[ "\0\0", - [ - /* :: */0, + /* :: */[ "\0\0", /* [] */0 ] @@ -2069,28 +1893,27 @@ function elfphdr(ty, off, sz, align) { } function elfgen(outf) { - var entry = opos[1]; + var entry = opos[0]; var main = Caml_curry.app1(addsym, "main"); var gmain = globs[main]; out(1217084452); out(311610844168); out(18616); - le(64, gmain[1]); - globs[main] = [ - /* record */0, - opos[1] - 8, - gmain[2] + le(64, gmain[0]); + globs[main] = /* record */[ + opos[0] - 8, + gmain[1] ]; out(65488); out(35271); load(0, 60); out(3845); - var off = textoff + gpos[1]; + var off = textoff + gpos[0]; var itr = function (f) { return Caml_curry.app1(symitr, function (i, s) { var g = globs[i]; - if (g[2] < 0 && g[1] !== 0) { - return Caml_curry.app3(f, s, s.length, g[1]); + if (g[1] < 0 && g[0] !== 0) { + return Caml_curry.app3(f, s, s.length, g[0]); } else { return 0; @@ -2102,54 +1925,48 @@ function elfgen(outf) { }; var patchloc = function (i, _) { var g = globs[i]; - if (g[2] >= 0 && g[2] < base) { - return patch(/* false */0, g[1], va(g[2])); + if (g[1] >= 0 && g[1] < base) { + return patch(/* false */0, g[0], va(g[1])); } - else if (g[2] >= 0) { - return patch(/* false */0, g[1], g[2]); + else if (g[1] >= 0) { + return patch(/* false */0, g[0], g[1]); } else { return 0; } }; Caml_curry.app1(symitr, patchloc); - var strtab = opos[1]; - ++ opos[1]; + var strtab = opos[0]; + ++ opos[0]; var dllen = 37; - $$String.blit("/lib64/ld-linux-x86-64.so.2\0libc.so.6", 0, obuf, opos[1], dllen); - opos[1] = opos[1] + dllen + 1; + $$String.blit("/lib64/ld-linux-x86-64.so.2\0libc.so.6", 0, obuf, opos[0], dllen); + opos[0] = opos[0] + dllen + 1; itr(function (s, sl, _) { - $$String.blit(s, 0, obuf, opos[1], sl); - opos[1] = opos[1] + sl + 1; + $$String.blit(s, 0, obuf, opos[0], sl); + opos[0] = opos[0] + sl + 1; return /* () */0; }); - opos[1] = opos[1] + 7 & -8; - var symtab = opos[1]; - var n = [ - 0, - dllen + 2 - ]; - opos[1] += 24; + opos[0] = opos[0] + 7 & -8; + var symtab = opos[0]; + var n = [dllen + 2]; + opos[0] += 24; itr(function (_, sl, _$1) { - le(32, n[1]); + le(32, n[0]); le(32, 16); le(64, 0); le(64, 0); - n[1] = n[1] + sl + 1; + n[0] = n[0] + sl + 1; return /* () */0; }); - var rel = opos[1]; - var n$1 = [ - 0, - 1 - ]; + var rel = opos[0]; + var n$1 = [1]; itr(function (_, _$1, l) { var genrel = function (_l) { while(true) { var l = _l; if (l !== 0) { le(64, va(l)); - le(64, 1 + (n$1[1] << 32)); + le(64, 1 + (n$1[0] << 32)); le(64, 0); _l = get32(l); continue ; @@ -2161,9 +1978,9 @@ function elfgen(outf) { }; }; genrel(l); - return ++ n$1[1]; + return ++ n$1[0]; }); - var hash = opos[1]; + var hash = opos[0]; var n$2 = ((rel - symtab) / 24 | 0) - 1; le(32, 1); le(32, n$2 + 1); @@ -2172,65 +1989,46 @@ function elfgen(outf) { le(32, i); } le(32, 0); - var dyn = opos[1]; + var dyn = opos[0]; List.iter(function (param) { return le(64, param); - }, [ - /* :: */0, + }, /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 29, - [ - /* :: */0, + /* :: */[ 4, - [ - /* :: */0, + /* :: */[ va(hash), - [ - /* :: */0, + /* :: */[ 5, - [ - /* :: */0, + /* :: */[ va(strtab), - [ - /* :: */0, + /* :: */[ 6, - [ - /* :: */0, + /* :: */[ va(symtab), - [ - /* :: */0, + /* :: */[ 7, - [ - /* :: */0, + /* :: */[ va(rel), - [ - /* :: */0, + /* :: */[ 8, - [ - /* :: */0, + /* :: */[ hash - rel, - [ - /* :: */0, + /* :: */[ 9, - [ - /* :: */0, + /* :: */[ 24, - [ - /* :: */0, + /* :: */[ 10, - [ - /* :: */0, + /* :: */[ symtab - strtab, - [ - /* :: */0, + /* :: */[ 11, - [ - /* :: */0, + /* :: */[ 24, - [ - /* :: */0, + /* :: */[ 0, /* [] */0 ] @@ -2252,20 +2050,18 @@ function elfgen(outf) { ] ] ]); - var tend = opos[1]; + var tend = opos[0]; Bytes.blit(obuf, 0, obuf, off, tend); - Bytes.blit(glo, 0, obuf, textoff, gpos[1]); + Bytes.blit(glo, 0, obuf, textoff, gpos[0]); Bytes.blit(elfhdr, 0, obuf, 0, 64); - opos[1] = 64; + opos[0] = 64; elfphdr(3, strtab + 1 + off, 28, 1); elfphdr(1, 0, tend + off, 2097152); elfphdr(2, dyn + off, tend - dyn, 8); - if (opos[1] !== textoff) { + if (opos[0] !== textoff) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "qcc.ml", 698, 2 @@ -2278,92 +2074,110 @@ function elfgen(outf) { function main() { var ppsym = function (param) { - switch (param[0]) { + switch (param.tag | 0) { case 0 : - return Caml_curry.app1(Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Operator '", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - "'\n", - /* End_of_format */0 - ] - ] - ], - "Operator '%s'\n" - ]), param[1]); + return Caml_curry.app1(Printf.printf(/* Format */{ + 0: /* String_literal */{ + 0: "Operator '", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: "'\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "Operator '%s'\n", + length: 2, + tag: 0 + }), param[0]); case 1 : - return Caml_curry.app1(Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Int literal ", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "Int literal %d\n" - ]), param[1]); + return Caml_curry.app1(Printf.printf(/* Format */{ + 0: /* String_literal */{ + 0: "Int literal ", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "Int literal %d\n", + length: 2, + tag: 0 + }), param[0]); case 2 : - return Caml_curry.app1(Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Str literal ", - [ - /* Caml_string */3, - /* No_padding */0, - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "Str literal %S\n" - ]), param[2]); + return Caml_curry.app1(Printf.printf(/* Format */{ + 0: /* String_literal */{ + 0: "Str literal ", + 1: /* Caml_string */{ + 0: /* No_padding */0, + 1: /* Char_literal */{ + 0: /* "\n" */10, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 2, + tag: 3 + }, + length: 2, + tag: 11 + }, + 1: "Str literal %S\n", + length: 2, + tag: 0 + }), param[1]); case 3 : - var i = param[1]; - return Caml_curry.app2(Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Symbol '", - [ - /* String */2, - /* No_padding */0, - [ - /* String_literal */11, - "' (", - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String_literal */11, - ")\n", - /* End_of_format */0 - ] - ] - ] - ] - ], - "Symbol '%s' (%d)\n" - ]), Caml_curry.app1(symstr, i), i); + var i = param[0]; + return Caml_curry.app2(Printf.printf(/* Format */{ + 0: /* String_literal */{ + 0: "Symbol '", + 1: /* String */{ + 0: /* No_padding */0, + 1: /* String_literal */{ + 0: "' (", + 1: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String_literal */{ + 0: ")\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + length: 2, + tag: 2 + }, + length: 2, + tag: 11 + }, + 1: "Symbol '%s' (%d)\n", + length: 2, + tag: 0 + }), Caml_curry.app1(symstr, i), i); } }; @@ -2371,39 +2185,37 @@ function main() { switch (f) { case "-blk" : var c = function (param) { - return block([ - /* tuple */0, - [ - 0, - 0 - ], + return block(/* tuple */[ + [0], 0 ], param); }; var stk = /* [] */0; - opos[1] = 0; + opos[0] = 0; Caml_curry.app1(c, stk); - return Pervasives.print_bytes(Bytes.sub(obuf, 0, opos[1])); + return Pervasives.print_bytes(Bytes.sub(obuf, 0, opos[0])); case "-lex" : var _param = /* () */0; while(true) { var tok = Caml_curry.app1(next$1, /* () */0); - if (tok[0]) { + if (tok.tag) { ppsym(tok); _param = /* () */0; continue ; } - else if (tok[1] === "EOF!") { - return Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "End of input stream\n", - /* End_of_format */0 - ], - "End of input stream\n" - ]); + else if (tok[0] === "EOF!") { + return Printf.printf(/* Format */{ + 0: /* String_literal */{ + 0: "End of input stream\n", + 1: /* End_of_format */0, + length: 2, + tag: 11 + }, + 1: "End of input stream\n", + length: 2, + tag: 0 + }); } else { ppsym(tok); @@ -2414,7 +2226,7 @@ function main() { }; default: var oc = Pervasives.open_out("a.out"); - inch[1] = Pervasives.open_in(f); + inch[0] = Pervasives.open_in(f); top(/* () */0); elfgen(oc); Caml_io.caml_ml_flush(oc); diff --git a/jscomp/test/queue_test.js b/jscomp/test/queue_test.js index 9b90ff16ce..21139d1e0f 100644 --- a/jscomp/test/queue_test.js +++ b/jscomp/test/queue_test.js @@ -7,7 +7,7 @@ var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); function to_array(q) { - var v = Caml_array.caml_make_vect(q[1], 0); + var v = Caml_array.caml_make_vect(q[0], 0); Queue.fold(function (i, e) { v[i] = e; return i + 1; @@ -16,8 +16,7 @@ function to_array(q) { } function queue_1(x) { - var q = [ - /* record */0, + var q = /* record */[ 0, /* None */0 ]; @@ -27,27 +26,26 @@ function queue_1(x) { return to_array(q); } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "simple push", function () { - var x = /* array */[ + var x = /* int array */[ 3, 4, 5, 2 ]; - return [ - /* Eq */0, - x, - queue_1(x) - ]; + return /* Eq */{ + 0: x, + 1: queue_1(x), + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/rec_module_test.d.ts b/jscomp/test/rec_module_test.d.ts new file mode 100644 index 0000000000..079209a6e7 --- /dev/null +++ b/jscomp/test/rec_module_test.d.ts @@ -0,0 +1,10 @@ +export var A: any ; +export var B: any ; +export var AA: any ; +export var BB: any ; +export var Even: any ; +export var Odd: any ; +export var AAA: any ; +export var ASet: any ; +export var suites: any ; + diff --git a/jscomp/test/rec_module_test.js b/jscomp/test/rec_module_test.js new file mode 100644 index 0000000000..56eda6bcc2 --- /dev/null +++ b/jscomp/test/rec_module_test.js @@ -0,0 +1,1231 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Mt = require("./mt"); +var CamlinternalMod = require("../stdlib/camlinternalMod"); +var Caml_curry = require("../runtime/caml_curry"); +var List = require("../stdlib/list"); +var Caml_string = require("../runtime/caml_string"); + +var A = CamlinternalMod.init_mod([ + "rec_module_test.ml", + 3, + 6 + ], [[0]]); + +var B = CamlinternalMod.init_mod([ + "rec_module_test.ml", + 11, + 6 + ], [[0]]); + +function even(n) { + if (n) { + if (n === 1) { + return /* false */0; + } + else { + return Caml_curry.app1(B[0], n - 1); + } + } + else { + return /* true */1; + } +} + +CamlinternalMod.update_mod([[0]], A, [even]); + +function odd(n) { + if (n === 1) { + return /* true */1; + } + else if (n) { + return Caml_curry.app1(A[0], n - 1); + } + else { + return /* false */0; + } +} + +CamlinternalMod.update_mod([[0]], B, [odd]); + +var AA = CamlinternalMod.init_mod([ + "rec_module_test.ml", + 21, + 6 + ], [[ + 0, + 0 + ]]); + +var BB = CamlinternalMod.init_mod([ + "rec_module_test.ml", + 31, + 6 + ], [[ + 0, + 0 + ]]); + +function even$1(n) { + if (n) { + if (n === 1) { + return /* false */0; + } + else { + return Caml_curry.app1(BB[0], n - 1); + } + } + else { + return /* true */1; + } +} + +function x() { + return Caml_curry.app1(BB[1], /* () */0) + 3; +} + +CamlinternalMod.update_mod([[ + 0, + 0 + ]], AA, [ + even$1, + x + ]); + +function odd$1(n) { + if (n === 1) { + return /* true */1; + } + else if (n) { + return Caml_curry.app1(AA[0], n - 1); + } + else { + return /* false */0; + } +} + +function y() { + return 32; +} + +CamlinternalMod.update_mod([[ + 0, + 0 + ]], BB, [ + odd$1, + y + ]); + +var Even = { + +}; + +var Odd = { + +}; + +var AAA = CamlinternalMod.init_mod([ + "rec_module_test.ml", + 55, + 2 + ], [[0]]); + +function height(param) { + if (param) { + return param[3]; + } + else { + return 0; + } +} + +function create(l, v, r) { + var hl = l ? l[3] : 0; + var hr = r ? r[3] : 0; + return /* Node */{ + 0: l, + 1: v, + 2: r, + 3: hl >= hr ? hl + 1 : hr + 1, + length: 4, + tag: 0 + }; +} + +function bal(l, v, r) { + var hl = l ? l[3] : 0; + var hr = r ? r[3] : 0; + if (hl > hr + 2) { + if (l) { + var lr = l[2]; + var lv = l[1]; + var ll = l[0]; + if (height(ll) >= height(lr)) { + return create(ll, lv, create(lr, v, r)); + } + else if (lr) { + return create(create(ll, lv, lr[0]), lr[1], create(lr[2], v, r)); + } + else { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "Set.bal" + ]; + } + } + else { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "Set.bal" + ]; + } + } + else if (hr > hl + 2) { + if (r) { + var rr = r[2]; + var rv = r[1]; + var rl = r[0]; + if (height(rr) >= height(rl)) { + return create(create(l, v, rl), rv, rr); + } + else if (rl) { + return create(create(l, v, rl[0]), rl[1], create(rl[2], rv, rr)); + } + else { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "Set.bal" + ]; + } + } + else { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "Set.bal" + ]; + } + } + else { + return /* Node */{ + 0: l, + 1: v, + 2: r, + 3: hl >= hr ? hl + 1 : hr + 1, + length: 4, + tag: 0 + }; + } +} + +function add(x, t) { + if (t) { + var r = t[2]; + var v = t[1]; + var l = t[0]; + var c = Caml_curry.app2(AAA[0], x, v); + if (c) { + if (c < 0) { + return bal(add(x, l), v, r); + } + else { + return bal(l, v, add(x, r)); + } + } + else { + return t; + } + } + else { + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }; + } +} + +function singleton(x) { + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }; +} + +function add_min_element(v, param) { + if (param) { + return bal(add_min_element(v, param[0]), param[1], param[2]); + } + else { + return singleton(v); + } +} + +function add_max_element(v, param) { + if (param) { + return bal(param[0], param[1], add_max_element(v, param[2])); + } + else { + return singleton(v); + } +} + +function join(l, v, r) { + if (l) { + if (r) { + var rh = r[3]; + var lh = l[3]; + if (lh > rh + 2) { + return bal(l[0], l[1], join(l[2], v, r)); + } + else if (rh > lh + 2) { + return bal(join(l, v, r[0]), r[1], r[2]); + } + else { + return create(l, v, r); + } + } + else { + return add_max_element(v, l); + } + } + else { + return add_min_element(v, r); + } +} + +function min_elt(_param) { + while(true) { + var param = _param; + if (param) { + var l = param[0]; + if (l) { + _param = l; + continue ; + + } + else { + return param[1]; + } + } + else { + throw Caml_builtin_exceptions.Not_found; + } + }; +} + +function max_elt(_param) { + while(true) { + var param = _param; + if (param) { + var r = param[2]; + if (r) { + _param = r; + continue ; + + } + else { + return param[1]; + } + } + else { + throw Caml_builtin_exceptions.Not_found; + } + }; +} + +function remove_min_elt(param) { + if (param) { + var l = param[0]; + if (l) { + return bal(remove_min_elt(l), param[1], param[2]); + } + else { + return param[2]; + } + } + else { + throw [ + Caml_builtin_exceptions.Invalid_argument, + "Set.remove_min_elt" + ]; + } +} + +function concat(t1, t2) { + if (t1) { + if (t2) { + return join(t1, min_elt(t2), remove_min_elt(t2)); + } + else { + return t1; + } + } + else { + return t2; + } +} + +function split(x, param) { + if (param) { + var r = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(AAA[0], x, v); + if (c) { + if (c < 0) { + var match = split(x, l); + return /* tuple */[ + match[0], + match[1], + join(match[2], v, r) + ]; + } + else { + var match$1 = split(x, r); + return /* tuple */[ + join(l, v, match$1[0]), + match$1[1], + match$1[2] + ]; + } + } + else { + return /* tuple */[ + l, + /* true */1, + r + ]; + } + } + else { + return /* tuple */[ + /* Empty */0, + /* false */0, + /* Empty */0 + ]; + } +} + +var empty = /* Empty */0; + +function is_empty(param) { + if (param) { + return /* false */0; + } + else { + return /* true */1; + } +} + +function mem(x, _param) { + while(true) { + var param = _param; + if (param) { + var c = Caml_curry.app2(AAA[0], x, param[1]); + if (c) { + _param = c < 0 ? param[0] : param[2]; + continue ; + + } + else { + return /* true */1; + } + } + else { + return /* false */0; + } + }; +} + +function remove(x, param) { + if (param) { + var r = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(AAA[0], x, v); + if (c) { + if (c < 0) { + return bal(remove(x, l), v, r); + } + else { + return bal(l, v, remove(x, r)); + } + } + else { + var t1 = l; + var t2 = r; + if (t1) { + if (t2) { + return bal(t1, min_elt(t2), remove_min_elt(t2)); + } + else { + return t1; + } + } + else { + return t2; + } + } + } + else { + return /* Empty */0; + } +} + +function union(s1, s2) { + if (s1) { + if (s2) { + var h2 = s2[3]; + var v2 = s2[1]; + var h1 = s1[3]; + var v1 = s1[1]; + if (h1 >= h2) { + if (h2 === 1) { + return add(v2, s1); + } + else { + var match = split(v1, s2); + return join(union(s1[0], match[0]), v1, union(s1[2], match[2])); + } + } + else if (h1 === 1) { + return add(v1, s2); + } + else { + var match$1 = split(v2, s1); + return join(union(match$1[0], s2[0]), v2, union(match$1[2], s2[2])); + } + } + else { + return s1; + } + } + else { + return s2; + } +} + +function inter(s1, s2) { + if (s1) { + if (s2) { + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; + var match = split(v1, s2); + var l2 = match[0]; + if (match[1] !== 0) { + return join(inter(l1, l2), v1, inter(r1, match[2])); + } + else { + return concat(inter(l1, l2), inter(r1, match[2])); + } + } + else { + return /* Empty */0; + } + } + else { + return /* Empty */0; + } +} + +function diff(s1, s2) { + if (s1) { + if (s2) { + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; + var match = split(v1, s2); + var l2 = match[0]; + if (match[1] !== 0) { + return concat(diff(l1, l2), diff(r1, match[2])); + } + else { + return join(diff(l1, l2), v1, diff(r1, match[2])); + } + } + else { + return s1; + } + } + else { + return /* Empty */0; + } +} + +function cons_enum(_s, _e) { + while(true) { + var e = _e; + var s = _s; + if (s) { + _e = /* More */{ + 0: s[1], + 1: s[2], + 2: e, + length: 3, + tag: 0 + }; + _s = s[0]; + continue ; + + } + else { + return e; + } + }; +} + +function compare(s1, s2) { + var _e1 = cons_enum(s1, /* End */0); + var _e2 = cons_enum(s2, /* End */0); + while(true) { + var e2 = _e2; + var e1 = _e1; + if (e1) { + if (e2) { + var c = Caml_curry.app2(AAA[0], e1[0], e2[0]); + if (c !== 0) { + return c; + } + else { + _e2 = cons_enum(e2[1], e2[2]); + _e1 = cons_enum(e1[1], e1[2]); + continue ; + + } + } + else { + return 1; + } + } + else if (e2) { + return -1; + } + else { + return 0; + } + }; +} + +function equal(s1, s2) { + return +(compare(s1, s2) === 0); +} + +function subset(_s1, _s2) { + while(true) { + var s2 = _s2; + var s1 = _s1; + if (s1) { + if (s2) { + var r2 = s2[2]; + var l2 = s2[0]; + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; + var c = Caml_curry.app2(AAA[0], v1, s2[1]); + if (c) { + if (c < 0) { + if (subset(/* Node */{ + 0: l1, + 1: v1, + 2: /* Empty */0, + 3: 0, + length: 4, + tag: 0 + }, l2)) { + _s1 = r1; + continue ; + + } + else { + return /* false */0; + } + } + else if (subset(/* Node */{ + 0: /* Empty */0, + 1: v1, + 2: r1, + 3: 0, + length: 4, + tag: 0 + }, r2)) { + _s1 = l1; + continue ; + + } + else { + return /* false */0; + } + } + else if (subset(l1, l2)) { + _s2 = r2; + _s1 = r1; + continue ; + + } + else { + return /* false */0; + } + } + else { + return /* false */0; + } + } + else { + return /* true */1; + } + }; +} + +function iter(f, _param) { + while(true) { + var param = _param; + if (param) { + iter(f, param[0]); + Caml_curry.app1(f, param[1]); + _param = param[2]; + continue ; + + } + else { + return /* () */0; + } + }; +} + +function fold(f, _s, _accu) { + while(true) { + var accu = _accu; + var s = _s; + if (s) { + _accu = Caml_curry.app2(f, s[1], fold(f, s[0], accu)); + _s = s[2]; + continue ; + + } + else { + return accu; + } + }; +} + +function for_all(p, _param) { + while(true) { + var param = _param; + if (param) { + if (Caml_curry.app1(p, param[1])) { + if (for_all(p, param[0])) { + _param = param[2]; + continue ; + + } + else { + return /* false */0; + } + } + else { + return /* false */0; + } + } + else { + return /* true */1; + } + }; +} + +function exists(p, _param) { + while(true) { + var param = _param; + if (param) { + if (Caml_curry.app1(p, param[1])) { + return /* true */1; + } + else if (exists(p, param[0])) { + return /* true */1; + } + else { + _param = param[2]; + continue ; + + } + } + else { + return /* false */0; + } + }; +} + +function filter(p, param) { + if (param) { + var v = param[1]; + var l$prime = filter(p, param[0]); + var pv = Caml_curry.app1(p, v); + var r$prime = filter(p, param[2]); + if (pv) { + return join(l$prime, v, r$prime); + } + else { + return concat(l$prime, r$prime); + } + } + else { + return /* Empty */0; + } +} + +function partition(p, param) { + if (param) { + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; + var pv = Caml_curry.app1(p, v); + var match$1 = partition(p, param[2]); + var rf = match$1[1]; + var rt = match$1[0]; + if (pv) { + return /* tuple */[ + join(lt, v, rt), + concat(lf, rf) + ]; + } + else { + return /* tuple */[ + concat(lt, rt), + join(lf, v, rf) + ]; + } + } + else { + return /* tuple */[ + /* Empty */0, + /* Empty */0 + ]; + } +} + +function cardinal(param) { + if (param) { + return cardinal(param[0]) + 1 + cardinal(param[2]); + } + else { + return 0; + } +} + +function elements_aux(_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (param) { + _param = param[0]; + _accu = /* :: */[ + param[1], + elements_aux(accu, param[2]) + ]; + continue ; + + } + else { + return accu; + } + }; +} + +function elements(s) { + return elements_aux(/* [] */0, s); +} + +function find(x, _param) { + while(true) { + var param = _param; + if (param) { + var v = param[1]; + var c = Caml_curry.app2(AAA[0], x, v); + if (c) { + _param = c < 0 ? param[0] : param[2]; + continue ; + + } + else { + return v; + } + } + else { + throw Caml_builtin_exceptions.Not_found; + } + }; +} + +function of_list(l) { + if (l) { + var match = l[1]; + var x0 = l[0]; + if (match) { + var match$1 = match[1]; + var x1 = match[0]; + if (match$1) { + var match$2 = match$1[1]; + var x2 = match$1[0]; + if (match$2) { + var match$3 = match$2[1]; + var x3 = match$2[0]; + if (match$3) { + if (match$3[1]) { + var l$1 = List.sort_uniq(AAA[0], l); + var sub = function (n, l) { + var exit = 0; + if (n > 3 || n < 0) { + exit = 1; + } + else { + switch (n) { + case 0 : + return /* tuple */[ + /* Empty */0, + l + ]; + case 1 : + if (l) { + return /* tuple */[ + /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + l[1] + ]; + } + else { + exit = 1; + } + break; + case 2 : + if (l) { + var match = l[1]; + if (match) { + return /* tuple */[ + /* Node */{ + 0: /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 1: match[0], + 2: /* Empty */0, + 3: 2, + length: 4, + tag: 0 + }, + match[1] + ]; + } + else { + exit = 1; + } + } + else { + exit = 1; + } + break; + case 3 : + if (l) { + var match$1 = l[1]; + if (match$1) { + var match$2 = match$1[1]; + if (match$2) { + return /* tuple */[ + /* Node */{ + 0: /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 1: match$1[0], + 2: /* Node */{ + 0: /* Empty */0, + 1: match$2[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 3: 2, + length: 4, + tag: 0 + }, + match$2[1] + ]; + } + else { + exit = 1; + } + } + else { + exit = 1; + } + } + else { + exit = 1; + } + break; + + } + } + if (exit === 1) { + var nl = n / 2 | 0; + var match$3 = sub(nl, l); + var l$1 = match$3[1]; + if (l$1) { + var match$4 = sub(n - nl - 1, l$1[1]); + return /* tuple */[ + create(match$3[0], l$1[0], match$4[0]), + match$4[1] + ]; + } + else { + throw [ + Caml_builtin_exceptions.Assert_failure, + [ + "set.ml", + 372, + 18 + ] + ]; + } + } + + }; + return sub(List.length(l$1), l$1)[0]; + } + else { + return add(match$3[0], add(x3, add(x2, add(x1, singleton(x0))))); + } + } + else { + return add(x3, add(x2, add(x1, singleton(x0)))); + } + } + else { + return add(x2, add(x1, singleton(x0))); + } + } + else { + return add(x1, singleton(x0)); + } + } + else { + return singleton(x0); + } + } + else { + return empty; + } +} + +var ASet = [ + empty, + is_empty, + mem, + add, + singleton, + remove, + union, + inter, + diff, + compare, + equal, + subset, + iter, + fold, + for_all, + exists, + filter, + partition, + cardinal, + elements, + min_elt, + max_elt, + min_elt, + split, + find, + of_list +]; + +function compare$1(t1, t2) { + if (t1.tag) { + if (t2.tag) { + return compare(t1[0], t2[0]); + } + else { + return -1; + } + } + else if (t2.tag) { + return 1; + } + else { + return Caml_string.caml_string_compare(t1[0], t2[0]); + } +} + +CamlinternalMod.update_mod([[0]], AAA, [compare$1]); + +var suites_000 = /* tuple */[ + "test1", + function () { + return /* Eq */{ + 0: /* tuple */[ + /* true */1, + /* true */1, + /* false */0, + /* false */0 + ], + 1: /* tuple */[ + Caml_curry.app1(A[0], 2), + Caml_curry.app1(AA[0], 4), + Caml_curry.app1(B[0], 2), + Caml_curry.app1(BB[0], 4) + ], + length: 2, + tag: 0 + }; + } +]; + +var suites_001 = /* :: */[ + /* tuple */[ + "test2", + function () { + return /* Eq */{ + 0: Caml_curry.app1(BB[1], /* () */0), + 1: 32, + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "test3", + function () { + return /* Eq */{ + 0: Caml_curry.app1(AA[1], /* () */0), + 1: 35, + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "test4", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_curry.app1(A[0], 2), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "test4", + function () { + return /* Eq */{ + 0: /* true */1, + 1: Caml_curry.app1(AA[0], 4), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "test5", + function () { + return /* Eq */{ + 0: /* false */0, + 1: Caml_curry.app1(B[0], 2), + length: 2, + tag: 0 + }; + } + ], + /* :: */[ + /* tuple */[ + "test6", + function () { + return /* Eq */{ + 0: 2, + 1: cardinal(of_list(/* :: */[ + /* Leaf */{ + 0: "a", + length: 1, + tag: 0 + }, + /* :: */[ + /* Leaf */{ + 0: "b", + length: 1, + tag: 0 + }, + /* :: */[ + /* Leaf */{ + 0: "a", + length: 1, + tag: 0 + }, + /* [] */0 + ] + ] + ])), + length: 2, + tag: 0 + }; + } + ], + /* [] */0 + ] + ] + ] + ] + ] +]; + +var suites = /* :: */[ + suites_000, + suites_001 +]; + +Mt.from_pair_suites("rec_module_test.ml", suites); + +exports.A = A; +exports.B = B; +exports.AA = AA; +exports.BB = BB; +exports.Even = Even; +exports.Odd = Odd; +exports.AAA = AAA; +exports.ASet = ASet; +exports.suites = suites; +/* A Not a pure module */ diff --git a/jscomp/test/rec_module_test.ml b/jscomp/test/rec_module_test.ml new file mode 100644 index 0000000000..52110b7d9b --- /dev/null +++ b/jscomp/test/rec_module_test.ml @@ -0,0 +1,80 @@ +module rec A : sig + val even : int -> bool +end = struct + let even n = + if n = 0 then true + else if n = 1 then false + else B.odd (n - 1) +end +and B : sig + val odd : int -> bool +end = struct + let odd n = + if n = 1 then true + else if n = 0 then false + else A.even (n - 1) +end + +module rec AA : sig + val even : int -> bool + val x : unit -> int +end = struct + let even n = + if n = 0 then true + else if n = 1 then false + else BB.odd (n - 1) + let x () = BB.y () + 3 +end +and BB : sig + val odd : int -> bool + val y : unit -> int +end = struct + let odd n = + if n = 1 then true + else if n = 0 then false + else AA.even (n - 1) + let y () = 32 +end + + +module rec Even : sig + type t = Zero | Succ of Odd.t +end = struct + type t = Zero | Succ of Odd.t +end +and Odd : sig + type t = Succ of Even.t +end = struct + type t = Succ of Even.t +end + +module rec AAA : sig + type t = Leaf of string | Node of ASet.t + val compare: t -> t -> int +end += struct + type t = Leaf of string | Node of ASet.t + let compare t1 t2 = + match (t1, t2) with + (Leaf s1, Leaf s2) -> Pervasives.compare s1 s2 + | (Leaf _, Node _) -> 1 + | (Node _, Leaf _) -> -1 + | (Node n1, Node n2) -> ASet.compare n1 n2 +end +and ASet : Set.S with type elt = AAA.t + = Set.Make(AAA) + + + +let suites = Mt.[ + "test1", (fun _ -> Eq ( (true,true,false,false), (A.even 2, AA.even 4, B.odd 2, BB.odd 4 ))); + "test2", (fun _ -> Eq( (BB.y (), 32))) ; + "test3", (fun _ -> Eq(AA.x (), 35)); + "test4", (fun _ -> Eq ( true, A.even 2 )); + "test4", (fun _ -> Eq ( true, AA.even 4 )); + "test5", (fun _ -> Eq(false, B.odd 2)); + "test6", (fun _ -> Eq(2 ,ASet.cardinal (ASet.of_list [Leaf "a" ; Leaf "b" ; Leaf "a"]))) +];; + +Mt.from_pair_suites __FILE__ suites + diff --git a/jscomp/test/rec_value_test.js b/jscomp/test/rec_value_test.js index 6d5a007ec5..e1274b5a49 100644 --- a/jscomp/test/rec_value_test.js +++ b/jscomp/test/rec_value_test.js @@ -1,49 +1,52 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_obj = require("../runtime/caml_obj"); var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var CamlinternalLazy = require("../stdlib/camlinternalLazy"); -var Mt = require("./mt"); -var Caml_primitive = require("../runtime/caml_primitive"); var List = require("../stdlib/list"); -var x = []; +var x = { + +}; -Caml_primitive.caml_update_dummy(x, [ - /* :: */0, +Caml_obj.caml_update_dummy(x, /* :: */[ 1, x ]); -var a = []; +var a = { + +}; -var b = []; +var b = { + +}; -var c = []; +var c = { + +}; -Caml_primitive.caml_update_dummy(a, [ - /* :: */0, +Caml_obj.caml_update_dummy(a, /* :: */[ 2, b ]); -Caml_primitive.caml_update_dummy(b, [ - /* :: */0, +Caml_obj.caml_update_dummy(b, /* :: */[ 3, c ]); -Caml_primitive.caml_update_dummy(c, [ - /* :: */0, +Caml_obj.caml_update_dummy(c, /* :: */[ 3, a ]); -var xx = []; +var xx = { + +}; -Caml_primitive.caml_update_dummy(xx, [ - /* :: */0, +Caml_obj.caml_update_dummy(xx, /* :: */[ 1, xx ]); @@ -59,38 +62,30 @@ function naive(n) { var one = 1; -var four = [ - 0, - 2 -]; +var four = [2]; -var three = [ - 0, - 3 -]; +var three = [3]; -var v = [ - 0, - function () { +var v = [function () { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "rec_value_test.ml", 23, 24 ] ]; - } -]; + }]; -var h = []; +var h = { + +}; -Caml_primitive.caml_update_dummy(h, [ - 250, - fib - ]); +Caml_obj.caml_update_dummy(h, { + 0: fib, + length: 1, + tag: 250 + }); function fib(n) { if (n > 3 || n < 0) { @@ -99,14 +94,14 @@ function fib(n) { else { switch (n) { case 0 : - return four[1]; + return four[0]; case 1 : return one; case 2 : - return three[1]; + return three[0]; case 3 : - var tag = Caml_obj_runtime.caml_obj_tag(h); - v[1] = tag === 250 ? fib : ( + var tag = h.tag | 0; + v[0] = tag === 250 ? fib : ( tag === 246 ? CamlinternalLazy.force_lazy_block(h) : h ); return one; @@ -115,31 +110,30 @@ function fib(n) { } } -var ys = []; +var ys = { + +}; -var xs = []; +var xs = { + +}; -Caml_primitive.caml_update_dummy(ys, [ - /* :: */0, +Caml_obj.caml_update_dummy(ys, /* :: */[ 1, ys ]); function _zs() { - return [ - /* tuple */0, + return /* tuple */[ List.hd(ys), - List.hd(xs[1]) + List.hd(xs[0]) ]; } -Caml_primitive.caml_update_dummy(xs, [ - /* tuple */0, - [ - /* :: */0, +Caml_obj.caml_update_dummy(xs, /* tuple */[ + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ List.hd(ys), /* [] */0 ] @@ -148,19 +142,18 @@ Caml_primitive.caml_update_dummy(xs, [ ]); function zs() { - return List.hd([ - /* :: */0, + return List.hd(/* :: */[ 2, /* [] */0 ]); } -var xs$1 = []; +var xs$1 = { + +}; -Caml_primitive.caml_update_dummy(xs$1, [ - /* tuple */0, - [ - /* :: */0, +Caml_obj.caml_update_dummy(xs$1, /* tuple */[ + /* :: */[ 2, /* [] */0 ], @@ -217,9 +210,9 @@ function even2(_n) { } function lazy_v() { - var tag = Caml_obj_runtime.caml_obj_tag(lazy_v); + var tag = lazy_v.tag | 0; if (tag === 250) { - return lazy_v[1]; + return lazy_v[0]; } else if (tag === 246) { return CamlinternalLazy.force_lazy_block(lazy_v); @@ -245,51 +238,46 @@ function sum(_acc, _n) { }; } -var fake_v = [ - /* :: */0, +var fake_v = /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, /* [] */0 ] ]; -var fake_y = [ - /* :: */0, +var fake_y = /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ]; -var fake_z = []; +var fake_z = { + +}; -Caml_primitive.caml_update_dummy(fake_z, [ - /* :: */0, +Caml_obj.caml_update_dummy(fake_z, /* :: */[ 1, fake_y ]); -var fake_y2 = [ - /* :: */0, +var fake_y2 = /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ]; -var fake_z2 = []; +var fake_z2 = { + +}; -Caml_primitive.caml_update_dummy(fake_z2, [ - /* :: */0, +Caml_obj.caml_update_dummy(fake_z2, /* :: */[ 1, - [ - /* :: */0, + /* :: */[ sum(0, 10), fake_y2 ] @@ -297,22 +285,20 @@ Caml_primitive.caml_update_dummy(fake_z2, [ var v$1 = 3; -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "hd", function () { - return [ - /* Eq */0, - 1, - List.hd(List.tl(x)) - ]; + return /* Eq */{ + 0: 1, + 1: List.hd(List.tl(x)), + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "mutual", function () { var $js; @@ -321,9 +307,9 @@ var suites_002 = [ if (b) { if (c) { if (a) { - var match = a[2]; + var match = a[1]; if (match) { - $js = match[1]; + $js = match[0]; } else { exit = 1; @@ -346,115 +332,97 @@ var suites_002 = [ } if (exit === 1) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "rec_value_test.ml", 97, 2 ] ]; } - return [ - /* Eq */0, - 3, - $js - ]; + return /* Eq */{ + 0: 3, + 1: $js, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "rec_sum", function () { - return [ - /* Eq */0, - 55, - sum(0, 10) - ]; + return /* Eq */{ + 0: 55, + 1: sum(0, 10), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "fake_rec", function () { - return [ - /* Eq */0, - [ - /* tuple */0, - [ - /* :: */0, + return /* Eq */{ + 0: /* tuple */[ + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, /* [] */0 ] ], - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ], - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ] ], - [ - /* :: */0, + /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 55, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ] ] ], - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ], 3 ], - [ - /* tuple */0, + 1: /* tuple */[ fake_v, fake_y, fake_z, fake_z2, fake_y2, v$1 - ] - ]; + ], + length: 2, + tag: 0 + }; } ], /* [] */0 @@ -462,14 +430,11 @@ var suites_002 = [ ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; -Mt.from_pair_suites("rec_value_test.ml", suites); - exports.x = x; exports.a = a; exports.b = b; diff --git a/jscomp/test/rec_value_test.ml b/jscomp/test/rec_value_test.ml index 4cc07964c0..3838f677e7 100644 --- a/jscomp/test/rec_value_test.ml +++ b/jscomp/test/rec_value_test.ml @@ -102,4 +102,4 @@ let suites = Mt.[ ] open Mt -;; from_pair_suites __FILE__ suites +(* ;; from_pair_suites __FILE__ suites *) diff --git a/jscomp/test/record_with_test.js b/jscomp/test/record_with_test.js index c30aa5a0a5..d89eaa3285 100644 --- a/jscomp/test/record_with_test.js +++ b/jscomp/test/record_with_test.js @@ -4,8 +4,7 @@ var Mt = require("./mt"); var Caml_curry = require("../runtime/caml_curry"); -var v = [ - /* record */0, +var v = /* record */[ /* None */0, 0, 0, @@ -17,36 +16,34 @@ var v = [ var newrecord = v.slice(); -newrecord[2] = 0; +newrecord[1] = 0; function f(g, h) { var newrecord = Caml_curry.app1(g, h).slice(); - newrecord[2] = 0; + newrecord[1] = 0; return newrecord; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "eq_with", function () { - return [ - /* Eq */0, - v, - newrecord - ]; + return /* Eq */{ + 0: v, + 1: newrecord, + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; Mt.from_pair_suites("record_with_test.ml", suites); -var uv = [ - /* record */0, +var uv = /* record */[ /* None */0, 1, 0, diff --git a/jscomp/test/runtime_encoding_test.d.ts b/jscomp/test/runtime_encoding_test.d.ts new file mode 100644 index 0000000000..89ba82deb4 --- /dev/null +++ b/jscomp/test/runtime_encoding_test.d.ts @@ -0,0 +1,2 @@ +export var v: any ; + diff --git a/jscomp/test/runtime_encoding_test.js b/jscomp/test/runtime_encoding_test.js new file mode 100644 index 0000000000..7757fa5fcf --- /dev/null +++ b/jscomp/test/runtime_encoding_test.js @@ -0,0 +1,11 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + + +var v = /* int array */[ + 0, + 1 +]; + +exports.v = v; +/* No side effect */ diff --git a/jscomp/test/runtime_encoding_test.ml b/jscomp/test/runtime_encoding_test.ml new file mode 100644 index 0000000000..3faf7a7add --- /dev/null +++ b/jscomp/test/runtime_encoding_test.ml @@ -0,0 +1,3 @@ + + +let v = [|0; 1 |] diff --git a/jscomp/test/simple_lexer_test.js b/jscomp/test/simple_lexer_test.js index b7c308fc85..9f62d3540a 100644 --- a/jscomp/test/simple_lexer_test.js +++ b/jscomp/test/simple_lexer_test.js @@ -7,8 +7,7 @@ var Assert = require("assert"); var Caml_curry = require("../runtime/caml_curry"); var $$String = require("../stdlib/string"); -var __ocaml_lex_tables = [ - /* record */0, +var __ocaml_lex_tables = /* record */[ "\0\0\xfd\xff\xfe\xff\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\x04\0\x01\0\x04\0\x03\0\0\0\x06\0\0\0\xff\xff", "\xff\xff\xff\xff\xff\xff\x01\0\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", "\x02\0\0\0\0\0\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\0\0", @@ -31,7 +30,7 @@ function __ocaml_lex_translate_rec(lexbuf, ___ocaml_lex_state) { var __ocaml_lex_state = ___ocaml_lex_state; var __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); if (__ocaml_lex_state$1 > 2 || __ocaml_lex_state$1 < 0) { - Caml_curry.app1(lexbuf[1], lexbuf); + Caml_curry.app1(lexbuf[0], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; continue ; @@ -41,7 +40,7 @@ function __ocaml_lex_translate_rec(lexbuf, ___ocaml_lex_state) { case 0 : return "." + __ocaml_lex_translate_rec(lexbuf, 0); case 1 : - var c = lexbuf[2][lexbuf[5]]; + var c = lexbuf[1][lexbuf[4]]; return $$String.make(1, c) + __ocaml_lex_translate_rec(lexbuf, 0); case 2 : return ""; @@ -51,8 +50,7 @@ function __ocaml_lex_translate_rec(lexbuf, ___ocaml_lex_state) { }; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "translate", function () { var lexbuf = Lexing.from_string("-- current_directory --"); @@ -61,9 +59,8 @@ var suites_001 = [ } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/stack_test.js b/jscomp/test/stack_test.js index 147abfa52c..b231c5457c 100644 --- a/jscomp/test/stack_test.js +++ b/jscomp/test/stack_test.js @@ -7,9 +7,8 @@ var List = require("../stdlib/list"); function to_list(v) { var acc = /* [] */0; - while(v[1] !== /* [] */0) { - acc = [ - /* :: */0, + while(v[0] !== /* [] */0) { + acc = /* :: */[ Stack.pop(v), acc ]; @@ -18,43 +17,36 @@ function to_list(v) { } function v() { - var v$1 = [ - /* record */0, - /* [] */0 - ]; + var v$1 = /* record */[/* [] */0]; Stack.push(3, v$1); Stack.push(4, v$1); Stack.push(1, v$1); return to_list(v$1); } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "push_test", function () { - return [ - /* Eq */0, - [ - /* :: */0, + return /* Eq */{ + 0: /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 4, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ] ], - v(/* () */0) - ]; + 1: v(/* () */0), + length: 2, + tag: 0 + }; } ]; -var suites = [ - /* :: */0, - suites_001, +var suites = /* :: */[ + suites_000, /* [] */0 ]; diff --git a/jscomp/test/string_runtime_test.js b/jscomp/test/string_runtime_test.js index 191d105192..c3cf883029 100644 --- a/jscomp/test/string_runtime_test.js +++ b/jscomp/test/string_runtime_test.js @@ -7,72 +7,61 @@ var $$String = require("../stdlib/string"); var List = require("../stdlib/list"); var Caml_string = require("../runtime/caml_string"); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "string_of_char_array", function () { - return [ - /* Eq */0, - Caml_string.caml_string_of_char_array(/* array */[ + return /* Eq */{ + 0: Caml_string.caml_string_of_char_array(/* int array */[ /* "a" */97, /* "b" */98, /* "c" */99 ]), - "abc" - ]; + 1: "abc", + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "caml_is_printable", function () { - return [ - /* Eq */0, - Caml_string.caml_is_printable(/* "a" */97), - /* true */1 - ]; + return /* Eq */{ + 0: Caml_string.caml_is_printable(/* "a" */97), + 1: /* true */1, + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "caml_string_of_bytes", function () { var match = List.split(List.map(function (x) { var len = x; var b = new Array(1000); Caml_string.caml_fill_string(b, 0, len, /* "c" */99); - return [ - /* tuple */0, + return /* tuple */[ Caml_string.bytes_to_string(b), $$String.init(len, function () { return /* "c" */99; }) ]; - }, [ - /* :: */0, + }, /* :: */[ 1000, - [ - /* :: */0, + /* :: */[ 1024, - [ - /* :: */0, + /* :: */[ 1025, - [ - /* :: */0, + /* :: */[ 4095, - [ - /* :: */0, + /* :: */[ 4096, - [ - /* :: */0, + /* :: */[ 5000, - [ - /* :: */0, + /* :: */[ 10000, /* [] */0 ] @@ -82,21 +71,21 @@ var suites_002 = [ ] ] ])); - return [ - /* Eq */0, - match[1], - match[2] - ]; + return /* Eq */{ + 0: match[0], + 1: match[1], + length: 2, + tag: 0 + }; } ], /* [] */0 ] ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("string_runtime_test.ml", suites); diff --git a/jscomp/test/string_test.js b/jscomp/test/string_test.js index ce1ab8d55b..12c46dec99 100644 --- a/jscomp/test/string_test.js +++ b/jscomp/test/string_test.js @@ -70,8 +70,7 @@ function rev_split_by_char(c, s) { try { var i$prime = $$String.index_from(s, i, c); var s$prime = $$String.sub(s, i, i$prime - i); - _l = s$prime === "" ? l : [ - /* :: */0, + _l = s$prime === "" ? l : /* :: */[ s$prime, l ]; @@ -81,8 +80,7 @@ function rev_split_by_char(c, s) { } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - return [ - /* :: */0, + return /* :: */[ $$String.sub(s, i, s.length - i), l ]; @@ -111,8 +109,7 @@ function xsplit(delim, s) { } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - return [ - /* :: */0, + return /* :: */[ $$String.sub(s, 0, i), l ]; @@ -122,14 +119,12 @@ function xsplit(delim, s) { } } if (exit === 1) { - var l_001 = $$String.sub(s, i$prime + 1, i - i$prime - 1); - var l$1 = [ - /* :: */0, - l_001, + var l_000 = $$String.sub(s, i$prime + 1, i - i$prime - 1); + var l$1 = /* :: */[ + l_000, l ]; - var l$2 = i$prime ? l$1 : [ - /* :: */0, + var l$2 = i$prime ? l$1 : /* :: */[ "", l$1 ]; @@ -150,119 +145,106 @@ function xsplit(delim, s) { } } -Mt.from_pair_suites("string_test.ml", [ - /* :: */0, - [ - /* tuple */0, +Mt.from_pair_suites("string_test.ml", /* :: */[ + /* tuple */[ "mutliple switch", function () { - return [ - /* Eq */0, - 9, - ff("4") - ]; + return /* Eq */{ + 0: 9, + 1: ff("4"), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "int switch", function () { - return [ - /* Eq */0, - 9, - gg(4) - ]; + return /* Eq */{ + 0: 9, + 1: gg(4), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "escape_normal", function () { - return [ - /* Eq */0, - "haha", - $$String.escaped("haha") - ]; + return /* Eq */{ + 0: "haha", + 1: $$String.escaped("haha"), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "escape_bytes", function () { - return [ - /* Eq */0, - Bytes.of_string("haha"), - Bytes.escaped(Bytes.of_string("haha")) - ]; + return /* Eq */{ + 0: Bytes.of_string("haha"), + 1: Bytes.escaped(Bytes.of_string("haha")), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "escape_quote", function () { - return [ - /* Eq */0, - '\\"\\"', - $$String.escaped('""') - ]; + return /* Eq */{ + 0: '\\"\\"', + 1: $$String.escaped('""'), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "rev_split_by_char", function () { - return [ - /* Eq */0, - [ - /* :: */0, + return /* Eq */{ + 0: /* :: */[ "", - [ - /* :: */0, + /* :: */[ "bbbb", - [ - /* :: */0, + /* :: */[ "bbbb", /* [] */0 ] ] ], - rev_split_by_char(/* "a" */97, "bbbbabbbba") - ]; + 1: rev_split_by_char(/* "a" */97, "bbbbabbbba"), + length: 2, + tag: 0 + }; } ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "xsplit", function () { - return [ - /* Eq */0, - [ - /* :: */0, + return /* Eq */{ + 0: /* :: */[ "a", - [ - /* :: */0, + /* :: */[ "b", - [ - /* :: */0, + /* :: */[ "c", /* [] */0 ] ] ], - xsplit(/* "." */46, "a.b.c") - ]; + 1: xsplit(/* "." */46, "a.b.c"), + length: 2, + tag: 0 + }; } ], /* [] */0 diff --git a/jscomp/test/tailcall_inline_test.js b/jscomp/test/tailcall_inline_test.js index 57d42e4354..7e2f171d29 100644 --- a/jscomp/test/tailcall_inline_test.js +++ b/jscomp/test/tailcall_inline_test.js @@ -29,14 +29,12 @@ function f() { return v; } -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "acc", function () { - return [ - /* Eq */0, - f(/* () */0), - /* array */[ + return /* Eq */{ + 0: f(/* () */0), + 1: /* array */[ 0, 1, 3, @@ -47,47 +45,44 @@ var suites_001 = [ 28, 36, 45 - ] - ]; + ], + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "array_to_list", function () { - return [ - /* Eq */0, - [ - /* :: */0, + return /* Eq */{ + 0: /* :: */[ 1, - [ - /* :: */0, + /* :: */[ 2, - [ - /* :: */0, + /* :: */[ 3, /* [] */0 ] ] ], - $$Array.to_list(/* array */[ + 1: $$Array.to_list(/* int array */[ 1, 2, 3 - ]) - ]; + ]), + length: 2, + tag: 0 + }; } ], /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("tailcall_inline_test.ml", suites); diff --git a/jscomp/test/test.mllib b/jscomp/test/test.mllib index a89af4ec2d..113b8d4053 100644 --- a/jscomp/test/test.mllib +++ b/jscomp/test/test.mllib @@ -167,4 +167,10 @@ const_defs const_defs_test genlex_test -cross_module_inline_test \ No newline at end of file +cross_module_inline_test +runtime_encoding_test +obj_magic_test +caml_compare_test +rec_module_test +guide_for_ext +local_exception_test \ No newline at end of file diff --git a/jscomp/test/test_ari.js b/jscomp/test/test_ari.js index 827f1be8f8..73253782d8 100644 --- a/jscomp/test/test_ari.js +++ b/jscomp/test/test_ari.js @@ -37,7 +37,7 @@ function length_aux(_len, _param) { var param = _param; var len = _len; if (param) { - _param = param[2]; + _param = param[1]; _len = len + 1; continue ; diff --git a/jscomp/test/test_array.js b/jscomp/test/test_array.js index 3f52b6ea90..94236f4616 100644 --- a/jscomp/test/test_array.js +++ b/jscomp/test/test_array.js @@ -10,33 +10,30 @@ new Array(30); var h = $$Array.sub(v, 0, 2); -var hhh = $$Array.append(/* array */[ +var hhh = $$Array.append(/* int array */[ 1, 2, 3, 4 - ], /* array */[ + ], /* int array */[ 1, 2, 3, 5 ]); -var u = Caml_array.caml_array_concat([ - /* :: */0, - /* array */[ +var u = Caml_array.caml_array_concat(/* :: */[ + /* int array */[ 1, 2 ], - [ - /* :: */0, - /* array */[ + /* :: */[ + /* int array */[ 2, 3 ], - [ - /* :: */0, - /* array */[ + /* :: */[ + /* int array */[ 3, 4 ], diff --git a/jscomp/test/test_array_append.js b/jscomp/test/test_array_append.js index f69e981f1f..19526e5b6c 100644 --- a/jscomp/test/test_array_append.js +++ b/jscomp/test/test_array_append.js @@ -3,10 +3,10 @@ var $$Array = require("../stdlib/array"); -var const_v = $$Array.append(/* array */[ +var const_v = $$Array.append(/* int array */[ 1, 2 - ], /* array */[3]); + ], /* int array */[3]); exports.const_v = const_v; /* const_v Not a pure module */ diff --git a/jscomp/test/test_array_primitive.js b/jscomp/test/test_array_primitive.js index 897881f2c9..e2ae7a2caf 100644 --- a/jscomp/test/test_array_primitive.js +++ b/jscomp/test/test_array_primitive.js @@ -14,7 +14,6 @@ function caml_array_sub(x, offset, len) { function caml_array_set(xs, index, newval) { if (index < 0 || index >= xs.length) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "index out of bounds" ]; @@ -28,7 +27,6 @@ function caml_array_set(xs, index, newval) { function caml_array_get(xs, index) { if (index < 0 || index >= xs.length) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "index out of bounds" ]; diff --git a/jscomp/test/test_bool_equal.js b/jscomp/test/test_bool_equal.js index 0d56641ab5..87d13425f5 100644 --- a/jscomp/test/test_bool_equal.js +++ b/jscomp/test/test_bool_equal.js @@ -23,10 +23,8 @@ function bool_equal(x, y) { function assertions() { if (!bool_equal(/* true */1, /* true */1)) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_bool_equal.ml", 21, 2 @@ -35,10 +33,8 @@ function assertions() { } if (!bool_equal(/* false */0, /* false */0)) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_bool_equal.ml", 22, 2 @@ -47,10 +43,8 @@ function assertions() { } if (bool_equal(/* true */1, /* false */0)) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_bool_equal.ml", 23, 2 @@ -59,10 +53,8 @@ function assertions() { } if (bool_equal(/* false */0, /* true */1)) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_bool_equal.ml", 24, 2 diff --git a/jscomp/test/test_char.js b/jscomp/test/test_char.js index d643fa7b60..9ca34db12f 100644 --- a/jscomp/test/test_char.js +++ b/jscomp/test/test_char.js @@ -10,7 +10,6 @@ function f(x) { function chr(n) { if (n < 0 || n > 255) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Char.chr" ]; diff --git a/jscomp/test/test_closure.js b/jscomp/test/test_closure.js index 8216a2c542..28b2e8e3a4 100644 --- a/jscomp/test/test_closure.js +++ b/jscomp/test/test_closure.js @@ -6,10 +6,7 @@ var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); var Caml_curry = require("../runtime/caml_curry"); -var v = [ - 0, - 0 -]; +var v = [0]; function f() { var arr = Caml_array.caml_make_vect(10, function () { @@ -18,7 +15,7 @@ function f() { for(var i = 0; i<= 9; ++i){ arr[i] = (function(i){ return function () { - v[1] += i; + v[0] += i; return /* () */0; } }(i)); @@ -32,12 +29,10 @@ $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, u); -if (v[1] !== 45) { +if (v[0] !== 45) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_closure.ml", 53, 2 diff --git a/jscomp/test/test_common.js b/jscomp/test/test_common.js index 9b1badbfa5..9d5308ec2b 100644 --- a/jscomp/test/test_common.js +++ b/jscomp/test/test_common.js @@ -3,17 +3,19 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var U = [ - 248, - "Test_common.U", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var U = { + 0: "Test_common.U", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; -var H = [ - 248, - "Test_common.H", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var H = { + 0: "Test_common.H", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; exports.U = U; exports.H = H; diff --git a/jscomp/test/test_demo.js b/jscomp/test/test_demo.js index 58ce15327d..6c6bcdd63e 100644 --- a/jscomp/test/test_demo.js +++ b/jscomp/test/test_demo.js @@ -14,20 +14,22 @@ function fib(n) { } function cons(x, y) { - return [ - /* Cons */0, - x, - y - ]; + return /* Cons */{ + 0: x, + 1: y, + length: 2, + tag: 0 + }; } function map(f, param) { if (param) { - return [ - /* Cons */0, - Caml_curry.app1(f, param[1]), - map(f, param[2]) - ]; + return /* Cons */{ + 0: Caml_curry.app1(f, param[0]), + 1: map(f, param[1]), + length: 2, + tag: 0 + }; } else { return /* Nil */0; diff --git a/jscomp/test/test_exception.js b/jscomp/test/test_exception.js index 2654d9e3fa..b22ff73a90 100644 --- a/jscomp/test/test_exception.js +++ b/jscomp/test/test_exception.js @@ -4,15 +4,15 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); var Test_common = require("./test_common"); -var Local = [ - 248, - "Test_exception.Local", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Local = { + 0: "Test_exception.Local", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function f() { throw [ - 0, Local, 3 ]; @@ -24,7 +24,6 @@ function g() { function h() { throw [ - 0, Test_common.U, 3 ]; @@ -36,7 +35,6 @@ function x() { function xx() { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "x" ]; diff --git a/jscomp/test/test_exception_escape.js b/jscomp/test/test_exception_escape.js index 1456030335..8ebe08ec8e 100644 --- a/jscomp/test/test_exception_escape.js +++ b/jscomp/test/test_exception_escape.js @@ -3,17 +3,17 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var A = [ - 248, - "Test_exception_escape.N.A", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var A = { + 0: "Test_exception_escape.N.A", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; var f; try { throw [ - 0, A, 3 ]; @@ -22,10 +22,7 @@ catch (exn){ f = 3; } -var N = [ - 0, - f -]; +var N = [f]; exports.N = N; /* f Not a pure module */ diff --git a/jscomp/test/test_fib.js b/jscomp/test/test_fib.js index 8d1f70e40a..166107a6c8 100644 --- a/jscomp/test/test_fib.js +++ b/jscomp/test/test_fib.js @@ -38,16 +38,17 @@ for(var i$1 = 10; i$1>= 0; --i$1){ var sumdown = v$1; function cons(x, y) { - return [ - /* Cons */0, - x, - y - ]; + return /* Cons */{ + 0: x, + 1: y, + length: 2, + tag: 0 + }; } function length(x) { if (x) { - return 1 + length(x[2]); + return 1 + length(x[1]); } else { return 0; @@ -56,11 +57,12 @@ function length(x) { function map(f, x) { if (x) { - return [ - /* Cons */0, - Caml_curry.app1(f, x[1]), - map(f, x[2]) - ]; + return /* Cons */{ + 0: Caml_curry.app1(f, x[0]), + 1: map(f, x[1]), + length: 2, + tag: 0 + }; } else { return /* Nil */0; diff --git a/jscomp/test/test_for_loop.js b/jscomp/test/test_for_loop.js index a1c1fda7e4..1498707450 100644 --- a/jscomp/test/test_for_loop.js +++ b/jscomp/test/test_for_loop.js @@ -19,10 +19,7 @@ function for_2(x) { } function for_3(x) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); @@ -30,7 +27,7 @@ function for_3(x) { var j = i * 2; arr[i] = (function(j){ return function () { - v[1] += j; + v[0] += j; return /* () */0; } }(j)); @@ -38,14 +35,11 @@ function for_3(x) { $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_4(x) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); @@ -54,7 +48,7 @@ function for_4(x) { var k = 2 * j; arr[i] = (function(k){ return function () { - v[1] += k; + v[0] += k; return /* () */0; } }(k)); @@ -62,14 +56,11 @@ function for_4(x) { $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_5(x, u) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); @@ -77,7 +68,7 @@ function for_5(x, u) { var k = 2 * u * u; arr[i] = (function(k){ return function () { - v[1] += k; + v[0] += k; return /* () */0; } }(k)); @@ -85,40 +76,28 @@ function for_5(x, u) { $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return v[1]; + return v[0]; } function for_6(x, u) { - var v = [ - 0, - 0 - ]; + var v = [0]; var arr = $$Array.map(function (_, _$1) { return /* () */0; }, x); - var v4 = [ - 0, - 0 - ]; - var v5 = [ - 0, - 0 - ]; - ++ v4[1]; + var v4 = [0]; + var v5 = [0]; + ++ v4[0]; for(var j = 0; j<= 1; ++j){ - ++ v5[1]; - var v2 = [ - 0, - 0 - ]; + ++ v5[0]; + var v2 = [0]; (function(v2){ for(var i = 0 ,i_finish = x.length; i<= i_finish; ++i){ var k = 2 * u * u; - var h = 2 * v5[1]; - ++ v2[1]; + var h = 2 * v5[0]; + ++ v2[0]; arr[i] = (function(k,h){ return function () { - v[1] = v[1] + k + v2[1] + u + v4[1] + v5[1] + h; + v[0] = v[0] + k + v2[0] + u + v4[0] + v5[0] + h; return /* () */0; } }(k,h)); @@ -128,7 +107,7 @@ function for_6(x, u) { $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); - return v[1]; + return v[0]; } exports.for_ = for_; diff --git a/jscomp/test/test_for_map.js b/jscomp/test/test_for_map.js index 2045c14960..a6df9a2d73 100644 --- a/jscomp/test/test_for_map.js +++ b/jscomp/test/test_for_map.js @@ -2,12 +2,12 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_obj = require("../runtime/caml_obj"); var Caml_curry = require("../runtime/caml_curry"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -17,45 +17,46 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function singleton(x, d) { - return [ - /* Node */0, - /* Empty */0, - x, - d, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: d, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -63,7 +64,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -71,19 +71,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -91,21 +90,21 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } @@ -120,11 +119,11 @@ function is_empty(param) { function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -134,25 +133,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -160,14 +161,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -180,9 +181,9 @@ function mem(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } @@ -200,17 +201,16 @@ function min_binding(_param) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -224,17 +224,16 @@ function max_binding(_param) { while(true) { var param = _param; if (param) { - var r = param[4]; + var r = param[3]; if (r) { _param = r; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -246,17 +245,16 @@ function max_binding(_param) { function remove_min_binding(param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal(remove_min_binding(l), param[2], param[3], param[4]); + return bal(remove_min_binding(l), param[1], param[2], param[3]); } else { - return param[4]; + return param[3]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.remove_min_elt" ]; @@ -265,11 +263,11 @@ function remove_min_binding(param) { function remove(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, d, r); @@ -284,7 +282,7 @@ function remove(x, param) { if (t1) { if (t2) { var match = min_binding(t2); - return bal(t1, match[1], match[2], remove_min_binding(t2)); + return bal(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -304,9 +302,9 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - iter(f, param[1]); - Caml_curry.app2(f, param[2], param[3]); - _param = param[4]; + iter(f, param[0]); + Caml_curry.app2(f, param[1], param[2]); + _param = param[3]; continue ; } @@ -318,17 +316,18 @@ function iter(f, _param) { function map(f, param) { if (param) { - var l$prime = map(f, param[1]); - var d$prime = Caml_curry.app1(f, param[3]); - var r$prime = map(f, param[4]); - return [ - /* Node */0, - l$prime, - param[2], - d$prime, - r$prime, - param[5] - ]; + var l$prime = map(f, param[0]); + var d$prime = Caml_curry.app1(f, param[2]); + var r$prime = map(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: param[1], + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -337,18 +336,19 @@ function map(f, param) { function mapi(f, param) { if (param) { - var v = param[2]; - var l$prime = mapi(f, param[1]); - var d$prime = Caml_curry.app2(f, v, param[3]); - var r$prime = mapi(f, param[4]); - return [ - /* Node */0, - l$prime, - v, - d$prime, - r$prime, - param[5] - ]; + var v = param[1]; + var l$prime = mapi(f, param[0]); + var d$prime = Caml_curry.app2(f, v, param[2]); + var r$prime = mapi(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: v, + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -360,8 +360,8 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold(f, m[0], accu)); + _m = m[3]; continue ; } @@ -375,9 +375,9 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { - if (for_all(p, param[1])) { - _param = param[4]; + if (Caml_curry.app2(p, param[1], param[2])) { + if (for_all(p, param[0])) { + _param = param[3]; continue ; } @@ -399,14 +399,14 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { + if (Caml_curry.app2(p, param[1], param[2])) { return /* true */1; } - else if (exists(p, param[1])) { + else if (exists(p, param[0])) { return /* true */1; } else { - _param = param[4]; + _param = param[3]; continue ; } @@ -419,7 +419,7 @@ function exists(p, _param) { function add_min_binding(k, v, param) { if (param) { - return bal(add_min_binding(k, v, param[1]), param[2], param[3], param[4]); + return bal(add_min_binding(k, v, param[0]), param[1], param[2], param[3]); } else { return singleton(k, v); @@ -428,7 +428,7 @@ function add_min_binding(k, v, param) { function add_max_binding(k, v, param) { if (param) { - return bal(param[1], param[2], param[3], add_max_binding(k, v, param[4])); + return bal(param[0], param[1], param[2], add_max_binding(k, v, param[3])); } else { return singleton(k, v); @@ -438,13 +438,13 @@ function add_max_binding(k, v, param) { function join(l, v, d, r) { if (l) { if (r) { - var rh = r[5]; - var lh = l[5]; + var rh = r[4]; + var lh = l[4]; if (lh > rh + 2) { - return bal(l[1], l[2], l[3], join(l[4], v, d, r)); + return bal(l[0], l[1], l[2], join(l[3], v, d, r)); } else if (rh > lh + 2) { - return bal(join(l, v, d, r[1]), r[2], r[3], r[4]); + return bal(join(l, v, d, r[0]), r[1], r[2], r[3]); } else { return create(l, v, d, r); @@ -463,7 +463,7 @@ function concat(t1, t2) { if (t1) { if (t2) { var match = min_binding(t2); - return join(t1, match[1], match[2], remove_min_binding(t2)); + return join(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -476,7 +476,7 @@ function concat(t1, t2) { function concat_or_join(t1, v, d, t2) { if (d) { - return join(t1, v, d[1], t2); + return join(t1, v, d[0], t2); } else { return concat(t1, t2); @@ -485,46 +485,39 @@ function concat_or_join(t1, v, d, t2) { function split(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { var match = split(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join(match[3], v, d, r) + join(match[2], v, d, r) ]; } else { var match$1 = split(x, r); - return [ - /* tuple */0, - join(l, v, d, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, - [ - /* Some */0, - d - ], + /* Some */[d], r ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* None */0, /* Empty */0 @@ -535,13 +528,10 @@ function split(x, param) { function merge(f, s1, s2) { var exit = 0; if (s1) { - var v1 = s1[2]; - if (s1[5] >= height(s2)) { + var v1 = s1[1]; + if (s1[4] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, Caml_curry.app3(f, v1, [ - /* Some */0, - s1[3] - ], match[2]), merge(f, s1[4], match[3])); + return concat_or_join(merge(f, s1[0], match[0]), v1, Caml_curry.app3(f, v1, /* Some */[s1[2]], match[1]), merge(f, s1[3], match[2])); } else { exit = 1; @@ -555,19 +545,14 @@ function merge(f, s1, s2) { } if (exit === 1) { if (s2) { - var v2 = s2[2]; + var v2 = s2[1]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, Caml_curry.app3(f, v2, match$1[2], [ - /* Some */0, - s2[3] - ]), merge(f, match$1[3], s2[4])); + return concat_or_join(merge(f, match$1[0], s2[0]), v2, Caml_curry.app3(f, v2, match$1[1], /* Some */[s2[2]]), merge(f, match$1[2], s2[3])); } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map.ml", 270, 10 @@ -580,11 +565,11 @@ function merge(f, s1, s2) { function filter(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var l$prime = filter(p, param[1]); + var d = param[2]; + var v = param[1]; + var l$prime = filter(p, param[0]); var pvd = Caml_curry.app2(p, v, d); - var r$prime = filter(p, param[4]); + var r$prime = filter(p, param[3]); if (pvd) { return join(l$prime, v, d, r$prime); } @@ -599,33 +584,30 @@ function filter(p, param) { function partition(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var match = partition(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var d = param[2]; + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pvd = Caml_curry.app2(p, v, d); - var match$1 = partition(p, param[4]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition(p, param[3]); + var rf = match$1[1]; + var rt = match$1[0]; if (pvd) { - return [ - /* tuple */0, + return /* tuple */[ join(lt, v, d, rt), concat(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat(lt, rt), join(lf, v, d, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -637,14 +619,15 @@ function cons_enum(_m, _e) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -662,18 +645,18 @@ function compare(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_primitive.caml_int_compare(e1[1], e2[1]); + var c = Caml_obj.caml_int_compare(e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -700,10 +683,10 @@ function equal(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - if (e1[1] === e2[1]) { - if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + if (e1[0] === e2[0]) { + if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -730,7 +713,7 @@ function equal(cmp, m1, m2) { function cardinal(param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[4]); + return cardinal(param[0]) + 1 + cardinal(param[3]); } else { return 0; @@ -742,15 +725,13 @@ function bindings_aux(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - [ - /* tuple */0, - param[2], - param[3] + _param = param[0]; + _accu = /* :: */[ + /* tuple */[ + param[1], + param[2] ], - bindings_aux(accu, param[4]) + bindings_aux(accu, param[3]) ]; continue ; @@ -766,7 +747,6 @@ function bindings(s) { } var IntMap = [ - 0, /* Empty */0, is_empty, mem, diff --git a/jscomp/test/test_format.js b/jscomp/test/test_format.js index a91756d8d3..96db161487 100644 --- a/jscomp/test/test_format.js +++ b/jscomp/test/test_format.js @@ -4,16 +4,18 @@ var Caml_curry = require("../runtime/caml_curry"); var Format = require("../stdlib/format"); -Caml_curry.app1(Format.fprintf(Format.std_formatter, [ - /* Format */0, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 - ], - "%d" - ]), 3); +Caml_curry.app1(Format.fprintf(Format.std_formatter, /* Format */{ + 0: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* End_of_format */0, + length: 4, + tag: 4 + }, + 1: "%d", + length: 2, + tag: 0 + }), 3); /* Not a pure module */ diff --git a/jscomp/test/test_formatter.js b/jscomp/test/test_formatter.js index 6693d0c88c..a119285dce 100644 --- a/jscomp/test/test_formatter.js +++ b/jscomp/test/test_formatter.js @@ -3,21 +3,24 @@ function f() { - return [ - /* Format */0, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "%d%s" - ]; + return /* Format */{ + 0: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 4, + tag: 4 + }, + 1: "%d%s", + length: 2, + tag: 0 + }; } exports.f = f; diff --git a/jscomp/test/test_generative_module.js b/jscomp/test/test_generative_module.js index fac76c6cf5..e8168eb3da 100644 --- a/jscomp/test/test_generative_module.js +++ b/jscomp/test/test_generative_module.js @@ -3,16 +3,10 @@ function M() { - return [ - 0, - 3 - ]; + return [3]; } -var V = [ - 0, - 3 -]; +var V = [3]; exports.M = M; exports.V = V; diff --git a/jscomp/test/test_global_print.js b/jscomp/test/test_global_print.js index 3bdc4fe62e..b0e305c912 100644 --- a/jscomp/test/test_global_print.js +++ b/jscomp/test/test_global_print.js @@ -3,15 +3,9 @@ var Hashtbl = require("../stdlib/hashtbl"); -var List = [ - 0, - 3 -]; +var List = [3]; -var X = [ - 0, - List -]; +var X = [List]; var Hashtbl$1 = 0; diff --git a/jscomp/test/test_google_closure.js b/jscomp/test/test_google_closure.js index fc027d5789..aa97651b87 100644 --- a/jscomp/test/test_google_closure.js +++ b/jscomp/test/test_google_closure.js @@ -23,9 +23,9 @@ for(var i = 0; i<= 2; ++i){ arr[i] = i + 1; } -var match_001 = "" + n; +var match_000 = "" + n; -var a = match_001; +var a = match_000; var b = 101; diff --git a/jscomp/test/test_include.js b/jscomp/test/test_include.js index b95b9a092a..7ab59826b5 100644 --- a/jscomp/test/test_include.js +++ b/jscomp/test/test_include.js @@ -6,9 +6,8 @@ var $$String = require("../stdlib/string"); var List = require("../stdlib/list"); function Make(U) { - var compare = U[1]; + var compare = U[0]; return [ - 0, compare, compare ]; @@ -17,7 +16,6 @@ function Make(U) { var compare = $$String.compare; var X = [ - 0, compare, compare ]; @@ -25,7 +23,6 @@ var X = [ var compare$1 = Test_order.compare; var U = [ - 0, compare$1, compare$1 ]; diff --git a/jscomp/test/test_incomplete.js b/jscomp/test/test_incomplete.js index 0b19e20d15..0bfd38626b 100644 --- a/jscomp/test/test_incomplete.js +++ b/jscomp/test/test_incomplete.js @@ -6,10 +6,8 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); function f(x) { if (x > 3 || x < 1) { throw [ - 0, Caml_builtin_exceptions.Match_failure, [ - 0, "test_incomplete.ml", 3, 2 @@ -31,13 +29,13 @@ function f2(x) { } function f3(x) { - switch (x[0]) { + switch (x.tag | 0) { case 0 : case 2 : - return x[1] + 1; + return x[0] + 1; case 1 : case 3 : - return x[1] + 2; + return x[0] + 2; } } diff --git a/jscomp/test/test_inline_map.js b/jscomp/test/test_inline_map.js index b871d3e78e..2373c7eda6 100644 --- a/jscomp/test/test_inline_map.js +++ b/jscomp/test/test_inline_map.js @@ -2,14 +2,14 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Assert = require("assert"); var Mt = require("./mt"); -var Caml_primitive = require("../runtime/caml_primitive"); var List = require("../stdlib/list"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -19,34 +19,34 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -54,7 +54,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -62,19 +61,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -82,31 +80,31 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -116,25 +114,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -142,14 +142,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -159,32 +159,24 @@ function find(x, _param) { } var m = List.fold_left(function (acc, param) { - return add(param[1], param[2], acc); - }, /* Empty */0, [ - /* :: */0, - [ - /* tuple */0, + return add(param[0], param[1], acc); + }, /* Empty */0, /* :: */[ + /* tuple */[ 10, /* "a" */97 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "b" */98 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 7, /* "c" */99 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 20, /* "d" */100 ], diff --git a/jscomp/test/test_inline_map2.js b/jscomp/test/test_inline_map2.js index e990e886a1..64a115f30c 100644 --- a/jscomp/test/test_inline_map2.js +++ b/jscomp/test/test_inline_map2.js @@ -2,15 +2,15 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Assert = require("assert"); var Mt = require("./mt"); -var Caml_primitive = require("../runtime/caml_primitive"); var List = require("../stdlib/list"); var Caml_string = require("../runtime/caml_string"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -20,34 +20,34 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -55,7 +55,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -63,19 +62,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -83,31 +81,31 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -117,25 +115,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -143,14 +143,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -160,32 +160,24 @@ function find(x, _param) { } var m = List.fold_left(function (acc, param) { - return add(param[1], param[2], acc); - }, /* Empty */0, [ - /* :: */0, - [ - /* tuple */0, + return add(param[0], param[1], acc); + }, /* Empty */0, /* :: */[ + /* tuple */[ 10, /* "a" */97 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "b" */98 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 7, /* "c" */99 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 20, /* "d" */100 ], @@ -197,7 +189,7 @@ var m = List.fold_left(function (acc, param) { function height$1(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -207,34 +199,34 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal$1(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } else if (lr) { - return create$1(create$1(ll, lv, ld, lr[1]), lr[2], lr[3], create$1(lr[4], x, d, r)); + return create$1(create$1(ll, lv, ld, lr[0]), lr[1], lr[2], create$1(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -242,7 +234,6 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -250,19 +241,18 @@ function bal$1(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create$1(create$1(l, x, d, rl[1]), rl[2], rl[3], create$1(rl[4], rv, rd, rr)); + return create$1(create$1(l, x, d, rl[0]), rl[1], rl[2], create$1(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -270,30 +260,30 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add$1(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -304,25 +294,27 @@ function add$1(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -330,14 +322,14 @@ function find$1(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -347,32 +339,24 @@ function find$1(x, _param) { } var s = List.fold_left(function (acc, param) { - return add$1(param[1], param[2], acc); - }, /* Empty */0, [ - /* :: */0, - [ - /* tuple */0, + return add$1(param[0], param[1], acc); + }, /* Empty */0, /* :: */[ + /* tuple */[ "10", /* "a" */97 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "3", /* "b" */98 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "7", /* "c" */99 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "20", /* "d" */100 ], diff --git a/jscomp/test/test_int_map_find.js b/jscomp/test/test_int_map_find.js index 7fdf24114e..cbab96e060 100644 --- a/jscomp/test/test_int_map_find.js +++ b/jscomp/test/test_int_map_find.js @@ -2,12 +2,12 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_obj = require("../runtime/caml_obj"); var List = require("../stdlib/list"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -17,34 +17,34 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -52,7 +52,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -60,19 +59,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -80,31 +78,31 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -114,55 +112,49 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } List.fold_left(function (acc, param) { - return add(param[1], param[2], acc); - }, /* Empty */0, [ - /* :: */0, - [ - /* tuple */0, + return add(param[0], param[1], acc); + }, /* Empty */0, /* :: */[ + /* tuple */[ 10, /* "a" */97 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "b" */98 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 7, /* "c" */99 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 20, /* "d" */100 ], diff --git a/jscomp/test/test_internalOO.js b/jscomp/test/test_internalOO.js index 8e9b3b81be..ba98e7783a 100644 --- a/jscomp/test/test_internalOO.js +++ b/jscomp/test/test_internalOO.js @@ -2,11 +2,10 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); +var Caml_obj = require("../runtime/caml_obj"); var Obj = require("../stdlib/obj"); var Caml_oo = require("../runtime/caml_oo"); var Sys = require("../stdlib/sys"); -var Caml_primitive = require("../runtime/caml_primitive"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); var Caml_curry = require("../runtime/caml_curry"); @@ -14,11 +13,10 @@ var Caml_string = require("../runtime/caml_string"); var List = require("../stdlib/list"); function copy(o) { - return Caml_builtin_exceptions.caml_set_oo_id(Caml_obj_runtime.caml_obj_dup(o)); + return Caml_builtin_exceptions.caml_set_oo_id(Caml_obj.caml_obj_dup(o)); } -var params = [ - /* record */0, +var params = /* record */[ /* true */1, /* true */1, /* true */1, @@ -48,7 +46,7 @@ function public_method_label(s) { function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -58,45 +56,46 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function singleton(x, d) { - return [ - /* Node */0, - /* Empty */0, - x, - d, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: d, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -104,7 +103,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -112,19 +110,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -132,21 +129,21 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } @@ -161,10 +158,10 @@ function is_empty(param) { function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -175,25 +172,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -201,14 +200,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -221,9 +220,9 @@ function mem(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } @@ -241,17 +240,16 @@ function min_binding(_param) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -265,17 +263,16 @@ function max_binding(_param) { while(true) { var param = _param; if (param) { - var r = param[4]; + var r = param[3]; if (r) { _param = r; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -287,17 +284,16 @@ function max_binding(_param) { function remove_min_binding(param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal(remove_min_binding(l), param[2], param[3], param[4]); + return bal(remove_min_binding(l), param[1], param[2], param[3]); } else { - return param[4]; + return param[3]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.remove_min_elt" ]; @@ -306,10 +302,10 @@ function remove_min_binding(param) { function remove(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -325,7 +321,7 @@ function remove(x, param) { if (t1) { if (t2) { var match = min_binding(t2); - return bal(t1, match[1], match[2], remove_min_binding(t2)); + return bal(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -345,9 +341,9 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - iter(f, param[1]); - Caml_curry.app2(f, param[2], param[3]); - _param = param[4]; + iter(f, param[0]); + Caml_curry.app2(f, param[1], param[2]); + _param = param[3]; continue ; } @@ -359,17 +355,18 @@ function iter(f, _param) { function map(f, param) { if (param) { - var l$prime = map(f, param[1]); - var d$prime = Caml_curry.app1(f, param[3]); - var r$prime = map(f, param[4]); - return [ - /* Node */0, - l$prime, - param[2], - d$prime, - r$prime, - param[5] - ]; + var l$prime = map(f, param[0]); + var d$prime = Caml_curry.app1(f, param[2]); + var r$prime = map(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: param[1], + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -378,18 +375,19 @@ function map(f, param) { function mapi(f, param) { if (param) { - var v = param[2]; - var l$prime = mapi(f, param[1]); - var d$prime = Caml_curry.app2(f, v, param[3]); - var r$prime = mapi(f, param[4]); - return [ - /* Node */0, - l$prime, - v, - d$prime, - r$prime, - param[5] - ]; + var v = param[1]; + var l$prime = mapi(f, param[0]); + var d$prime = Caml_curry.app2(f, v, param[2]); + var r$prime = mapi(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: v, + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -401,8 +399,8 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold(f, m[0], accu)); + _m = m[3]; continue ; } @@ -416,9 +414,9 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { - if (for_all(p, param[1])) { - _param = param[4]; + if (Caml_curry.app2(p, param[1], param[2])) { + if (for_all(p, param[0])) { + _param = param[3]; continue ; } @@ -440,14 +438,14 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { + if (Caml_curry.app2(p, param[1], param[2])) { return /* true */1; } - else if (exists(p, param[1])) { + else if (exists(p, param[0])) { return /* true */1; } else { - _param = param[4]; + _param = param[3]; continue ; } @@ -460,7 +458,7 @@ function exists(p, _param) { function add_min_binding(k, v, param) { if (param) { - return bal(add_min_binding(k, v, param[1]), param[2], param[3], param[4]); + return bal(add_min_binding(k, v, param[0]), param[1], param[2], param[3]); } else { return singleton(k, v); @@ -469,7 +467,7 @@ function add_min_binding(k, v, param) { function add_max_binding(k, v, param) { if (param) { - return bal(param[1], param[2], param[3], add_max_binding(k, v, param[4])); + return bal(param[0], param[1], param[2], add_max_binding(k, v, param[3])); } else { return singleton(k, v); @@ -479,13 +477,13 @@ function add_max_binding(k, v, param) { function join(l, v, d, r) { if (l) { if (r) { - var rh = r[5]; - var lh = l[5]; + var rh = r[4]; + var lh = l[4]; if (lh > rh + 2) { - return bal(l[1], l[2], l[3], join(l[4], v, d, r)); + return bal(l[0], l[1], l[2], join(l[3], v, d, r)); } else if (rh > lh + 2) { - return bal(join(l, v, d, r[1]), r[2], r[3], r[4]); + return bal(join(l, v, d, r[0]), r[1], r[2], r[3]); } else { return create(l, v, d, r); @@ -504,7 +502,7 @@ function concat(t1, t2) { if (t1) { if (t2) { var match = min_binding(t2); - return join(t1, match[1], match[2], remove_min_binding(t2)); + return join(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -517,7 +515,7 @@ function concat(t1, t2) { function concat_or_join(t1, v, d, t2) { if (d) { - return join(t1, v, d[1], t2); + return join(t1, v, d[0], t2); } else { return concat(t1, t2); @@ -526,46 +524,39 @@ function concat_or_join(t1, v, d, t2) { function split(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { var match = split(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join(match[3], v, d, r) + join(match[2], v, d, r) ]; } else { var match$1 = split(x, r); - return [ - /* tuple */0, - join(l, v, d, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, - [ - /* Some */0, - d - ], + /* Some */[d], r ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* None */0, /* Empty */0 @@ -576,13 +567,10 @@ function split(x, param) { function merge(f, s1, s2) { var exit = 0; if (s1) { - var v1 = s1[2]; - if (s1[5] >= height(s2)) { + var v1 = s1[1]; + if (s1[4] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, Caml_curry.app3(f, v1, [ - /* Some */0, - s1[3] - ], match[2]), merge(f, s1[4], match[3])); + return concat_or_join(merge(f, s1[0], match[0]), v1, Caml_curry.app3(f, v1, /* Some */[s1[2]], match[1]), merge(f, s1[3], match[2])); } else { exit = 1; @@ -596,19 +584,14 @@ function merge(f, s1, s2) { } if (exit === 1) { if (s2) { - var v2 = s2[2]; + var v2 = s2[1]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, Caml_curry.app3(f, v2, match$1[2], [ - /* Some */0, - s2[3] - ]), merge(f, match$1[3], s2[4])); + return concat_or_join(merge(f, match$1[0], s2[0]), v2, Caml_curry.app3(f, v2, match$1[1], /* Some */[s2[2]]), merge(f, match$1[2], s2[3])); } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map.ml", 270, 10 @@ -621,11 +604,11 @@ function merge(f, s1, s2) { function filter(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var l$prime = filter(p, param[1]); + var d = param[2]; + var v = param[1]; + var l$prime = filter(p, param[0]); var pvd = Caml_curry.app2(p, v, d); - var r$prime = filter(p, param[4]); + var r$prime = filter(p, param[3]); if (pvd) { return join(l$prime, v, d, r$prime); } @@ -640,33 +623,30 @@ function filter(p, param) { function partition(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var match = partition(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var d = param[2]; + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pvd = Caml_curry.app2(p, v, d); - var match$1 = partition(p, param[4]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition(p, param[3]); + var rf = match$1[1]; + var rt = match$1[0]; if (pvd) { - return [ - /* tuple */0, + return /* tuple */[ join(lt, v, d, rt), concat(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat(lt, rt), join(lf, v, d, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -678,14 +658,15 @@ function cons_enum(_m, _e) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -703,18 +684,18 @@ function compare(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_string.caml_string_compare(e1[1], e2[1]); + var c = Caml_string.caml_string_compare(e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -741,12 +722,12 @@ function equal(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - if (Caml_string.caml_string_compare(e1[1], e2[1])) { + if (Caml_string.caml_string_compare(e1[0], e2[0])) { return /* false */0; } - else if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + else if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -769,7 +750,7 @@ function equal(cmp, m1, m2) { function cardinal(param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[4]); + return cardinal(param[0]) + 1 + cardinal(param[3]); } else { return 0; @@ -781,15 +762,13 @@ function bindings_aux(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - [ - /* tuple */0, - param[2], - param[3] + _param = param[0]; + _accu = /* :: */[ + /* tuple */[ + param[1], + param[2] ], - bindings_aux(accu, param[4]) + bindings_aux(accu, param[3]) ]; continue ; @@ -805,7 +784,6 @@ function bindings(s) { } var Vars = [ - 0, /* Empty */0, is_empty, mem, @@ -834,7 +812,7 @@ var Vars = [ function height$1(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -844,45 +822,46 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function singleton$1(x, d) { - return [ - /* Node */0, - /* Empty */0, - x, - d, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: d, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } function bal$1(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } else if (lr) { - return create$1(create$1(ll, lv, ld, lr[1]), lr[2], lr[3], create$1(lr[4], x, d, r)); + return create$1(create$1(ll, lv, ld, lr[0]), lr[1], lr[2], create$1(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -890,7 +869,6 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -898,19 +876,18 @@ function bal$1(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create$1(create$1(l, x, d, rl[1]), rl[2], rl[3], create$1(rl[4], rv, rd, rr)); + return create$1(create$1(l, x, d, rl[0]), rl[1], rl[2], create$1(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -918,21 +895,21 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } @@ -947,10 +924,10 @@ function is_empty$1(param) { function add$1(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -961,25 +938,27 @@ function add$1(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -987,14 +966,14 @@ function find$1(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -1007,9 +986,9 @@ function mem$1(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } @@ -1027,17 +1006,16 @@ function min_binding$1(_param) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -1051,17 +1029,16 @@ function max_binding$1(_param) { while(true) { var param = _param; if (param) { - var r = param[4]; + var r = param[3]; if (r) { _param = r; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -1073,17 +1050,16 @@ function max_binding$1(_param) { function remove_min_binding$1(param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal$1(remove_min_binding$1(l), param[2], param[3], param[4]); + return bal$1(remove_min_binding$1(l), param[1], param[2], param[3]); } else { - return param[4]; + return param[3]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.remove_min_elt" ]; @@ -1092,10 +1068,10 @@ function remove_min_binding$1(param) { function remove$1(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -1111,7 +1087,7 @@ function remove$1(x, param) { if (t1) { if (t2) { var match = min_binding$1(t2); - return bal$1(t1, match[1], match[2], remove_min_binding$1(t2)); + return bal$1(t1, match[0], match[1], remove_min_binding$1(t2)); } else { return t1; @@ -1131,9 +1107,9 @@ function iter$1(f, _param) { while(true) { var param = _param; if (param) { - iter$1(f, param[1]); - Caml_curry.app2(f, param[2], param[3]); - _param = param[4]; + iter$1(f, param[0]); + Caml_curry.app2(f, param[1], param[2]); + _param = param[3]; continue ; } @@ -1145,17 +1121,18 @@ function iter$1(f, _param) { function map$1(f, param) { if (param) { - var l$prime = map$1(f, param[1]); - var d$prime = Caml_curry.app1(f, param[3]); - var r$prime = map$1(f, param[4]); - return [ - /* Node */0, - l$prime, - param[2], - d$prime, - r$prime, - param[5] - ]; + var l$prime = map$1(f, param[0]); + var d$prime = Caml_curry.app1(f, param[2]); + var r$prime = map$1(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: param[1], + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -1164,18 +1141,19 @@ function map$1(f, param) { function mapi$1(f, param) { if (param) { - var v = param[2]; - var l$prime = mapi$1(f, param[1]); - var d$prime = Caml_curry.app2(f, v, param[3]); - var r$prime = mapi$1(f, param[4]); - return [ - /* Node */0, - l$prime, - v, - d$prime, - r$prime, - param[5] - ]; + var v = param[1]; + var l$prime = mapi$1(f, param[0]); + var d$prime = Caml_curry.app2(f, v, param[2]); + var r$prime = mapi$1(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: v, + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -1187,8 +1165,8 @@ function fold$1(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold$1(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold$1(f, m[0], accu)); + _m = m[3]; continue ; } @@ -1202,9 +1180,9 @@ function for_all$1(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { - if (for_all$1(p, param[1])) { - _param = param[4]; + if (Caml_curry.app2(p, param[1], param[2])) { + if (for_all$1(p, param[0])) { + _param = param[3]; continue ; } @@ -1226,14 +1204,14 @@ function exists$1(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { + if (Caml_curry.app2(p, param[1], param[2])) { return /* true */1; } - else if (exists$1(p, param[1])) { + else if (exists$1(p, param[0])) { return /* true */1; } else { - _param = param[4]; + _param = param[3]; continue ; } @@ -1246,7 +1224,7 @@ function exists$1(p, _param) { function add_min_binding$1(k, v, param) { if (param) { - return bal$1(add_min_binding$1(k, v, param[1]), param[2], param[3], param[4]); + return bal$1(add_min_binding$1(k, v, param[0]), param[1], param[2], param[3]); } else { return singleton$1(k, v); @@ -1255,7 +1233,7 @@ function add_min_binding$1(k, v, param) { function add_max_binding$1(k, v, param) { if (param) { - return bal$1(param[1], param[2], param[3], add_max_binding$1(k, v, param[4])); + return bal$1(param[0], param[1], param[2], add_max_binding$1(k, v, param[3])); } else { return singleton$1(k, v); @@ -1265,13 +1243,13 @@ function add_max_binding$1(k, v, param) { function join$1(l, v, d, r) { if (l) { if (r) { - var rh = r[5]; - var lh = l[5]; + var rh = r[4]; + var lh = l[4]; if (lh > rh + 2) { - return bal$1(l[1], l[2], l[3], join$1(l[4], v, d, r)); + return bal$1(l[0], l[1], l[2], join$1(l[3], v, d, r)); } else if (rh > lh + 2) { - return bal$1(join$1(l, v, d, r[1]), r[2], r[3], r[4]); + return bal$1(join$1(l, v, d, r[0]), r[1], r[2], r[3]); } else { return create$1(l, v, d, r); @@ -1290,7 +1268,7 @@ function concat$1(t1, t2) { if (t1) { if (t2) { var match = min_binding$1(t2); - return join$1(t1, match[1], match[2], remove_min_binding$1(t2)); + return join$1(t1, match[0], match[1], remove_min_binding$1(t2)); } else { return t1; @@ -1303,7 +1281,7 @@ function concat$1(t1, t2) { function concat_or_join$1(t1, v, d, t2) { if (d) { - return join$1(t1, v, d[1], t2); + return join$1(t1, v, d[0], t2); } else { return concat$1(t1, t2); @@ -1312,46 +1290,39 @@ function concat_or_join$1(t1, v, d, t2) { function split$1(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { var match = split$1(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join$1(match[3], v, d, r) + join$1(match[2], v, d, r) ]; } else { var match$1 = split$1(x, r); - return [ - /* tuple */0, - join$1(l, v, d, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join$1(l, v, d, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, - [ - /* Some */0, - d - ], + /* Some */[d], r ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* None */0, /* Empty */0 @@ -1362,13 +1333,10 @@ function split$1(x, param) { function merge$1(f, s1, s2) { var exit = 0; if (s1) { - var v1 = s1[2]; - if (s1[5] >= height$1(s2)) { + var v1 = s1[1]; + if (s1[4] >= height$1(s2)) { var match = split$1(v1, s2); - return concat_or_join$1(merge$1(f, s1[1], match[1]), v1, Caml_curry.app3(f, v1, [ - /* Some */0, - s1[3] - ], match[2]), merge$1(f, s1[4], match[3])); + return concat_or_join$1(merge$1(f, s1[0], match[0]), v1, Caml_curry.app3(f, v1, /* Some */[s1[2]], match[1]), merge$1(f, s1[3], match[2])); } else { exit = 1; @@ -1382,19 +1350,14 @@ function merge$1(f, s1, s2) { } if (exit === 1) { if (s2) { - var v2 = s2[2]; + var v2 = s2[1]; var match$1 = split$1(v2, s1); - return concat_or_join$1(merge$1(f, match$1[1], s2[1]), v2, Caml_curry.app3(f, v2, match$1[2], [ - /* Some */0, - s2[3] - ]), merge$1(f, match$1[3], s2[4])); + return concat_or_join$1(merge$1(f, match$1[0], s2[0]), v2, Caml_curry.app3(f, v2, match$1[1], /* Some */[s2[2]]), merge$1(f, match$1[2], s2[3])); } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map.ml", 270, 10 @@ -1407,11 +1370,11 @@ function merge$1(f, s1, s2) { function filter$1(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var l$prime = filter$1(p, param[1]); + var d = param[2]; + var v = param[1]; + var l$prime = filter$1(p, param[0]); var pvd = Caml_curry.app2(p, v, d); - var r$prime = filter$1(p, param[4]); + var r$prime = filter$1(p, param[3]); if (pvd) { return join$1(l$prime, v, d, r$prime); } @@ -1426,33 +1389,30 @@ function filter$1(p, param) { function partition$1(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var match = partition$1(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var d = param[2]; + var v = param[1]; + var match = partition$1(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pvd = Caml_curry.app2(p, v, d); - var match$1 = partition$1(p, param[4]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition$1(p, param[3]); + var rf = match$1[1]; + var rt = match$1[0]; if (pvd) { - return [ - /* tuple */0, + return /* tuple */[ join$1(lt, v, d, rt), concat$1(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat$1(lt, rt), join$1(lf, v, d, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -1464,14 +1424,15 @@ function cons_enum$1(_m, _e) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -1489,18 +1450,18 @@ function compare$1(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_string.caml_string_compare(e1[1], e2[1]); + var c = Caml_string.caml_string_compare(e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum$1(e2[3], e2[4]); - _e1 = cons_enum$1(e1[3], e1[4]); + _e2 = cons_enum$1(e2[2], e2[3]); + _e1 = cons_enum$1(e1[2], e1[3]); continue ; } @@ -1527,12 +1488,12 @@ function equal$1(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - if (Caml_string.caml_string_compare(e1[1], e2[1])) { + if (Caml_string.caml_string_compare(e1[0], e2[0])) { return /* false */0; } - else if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum$1(e2[3], e2[4]); - _e1 = cons_enum$1(e1[3], e1[4]); + else if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum$1(e2[2], e2[3]); + _e1 = cons_enum$1(e1[2], e1[3]); continue ; } @@ -1555,7 +1516,7 @@ function equal$1(cmp, m1, m2) { function cardinal$1(param) { if (param) { - return cardinal$1(param[1]) + 1 + cardinal$1(param[4]); + return cardinal$1(param[0]) + 1 + cardinal$1(param[3]); } else { return 0; @@ -1567,15 +1528,13 @@ function bindings_aux$1(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - [ - /* tuple */0, - param[2], - param[3] + _param = param[0]; + _accu = /* :: */[ + /* tuple */[ + param[1], + param[2] ], - bindings_aux$1(accu, param[4]) + bindings_aux$1(accu, param[3]) ]; continue ; @@ -1591,7 +1550,6 @@ function bindings$1(s) { } var Meths = [ - 0, /* Empty */0, is_empty$1, mem$1, @@ -1620,7 +1578,7 @@ var Meths = [ function height$2(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -1630,45 +1588,46 @@ function height$2(param) { function create$2(l, x, d, r) { var hl = height$2(l); var hr = height$2(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function singleton$2(x, d) { - return [ - /* Node */0, - /* Empty */0, - x, - d, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: d, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } function bal$2(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height$2(ll) >= height$2(lr)) { return create$2(ll, lv, ld, create$2(lr, x, d, r)); } else if (lr) { - return create$2(create$2(ll, lv, ld, lr[1]), lr[2], lr[3], create$2(lr[4], x, d, r)); + return create$2(create$2(ll, lv, ld, lr[0]), lr[1], lr[2], create$2(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -1676,7 +1635,6 @@ function bal$2(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -1684,19 +1642,18 @@ function bal$2(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height$2(rr) >= height$2(rl)) { return create$2(create$2(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create$2(create$2(l, x, d, rl[1]), rl[2], rl[3], create$2(rl[4], rv, rd, rr)); + return create$2(create$2(l, x, d, rl[0]), rl[1], rl[2], create$2(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -1704,21 +1661,21 @@ function bal$2(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } @@ -1733,11 +1690,11 @@ function is_empty$2(param) { function add$2(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal$2(add$2(x, data, l), v, d, r); @@ -1747,25 +1704,27 @@ function add$2(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -1773,14 +1732,14 @@ function find$2(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -1793,9 +1752,9 @@ function mem$2(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } @@ -1813,17 +1772,16 @@ function min_binding$2(_param) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -1837,17 +1795,16 @@ function max_binding$2(_param) { while(true) { var param = _param; if (param) { - var r = param[4]; + var r = param[3]; if (r) { _param = r; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -1859,17 +1816,16 @@ function max_binding$2(_param) { function remove_min_binding$2(param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal$2(remove_min_binding$2(l), param[2], param[3], param[4]); + return bal$2(remove_min_binding$2(l), param[1], param[2], param[3]); } else { - return param[4]; + return param[3]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.remove_min_elt" ]; @@ -1878,11 +1834,11 @@ function remove_min_binding$2(param) { function remove$2(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal$2(remove$2(x, l), v, d, r); @@ -1897,7 +1853,7 @@ function remove$2(x, param) { if (t1) { if (t2) { var match = min_binding$2(t2); - return bal$2(t1, match[1], match[2], remove_min_binding$2(t2)); + return bal$2(t1, match[0], match[1], remove_min_binding$2(t2)); } else { return t1; @@ -1917,9 +1873,9 @@ function iter$2(f, _param) { while(true) { var param = _param; if (param) { - iter$2(f, param[1]); - Caml_curry.app2(f, param[2], param[3]); - _param = param[4]; + iter$2(f, param[0]); + Caml_curry.app2(f, param[1], param[2]); + _param = param[3]; continue ; } @@ -1931,17 +1887,18 @@ function iter$2(f, _param) { function map$2(f, param) { if (param) { - var l$prime = map$2(f, param[1]); - var d$prime = Caml_curry.app1(f, param[3]); - var r$prime = map$2(f, param[4]); - return [ - /* Node */0, - l$prime, - param[2], - d$prime, - r$prime, - param[5] - ]; + var l$prime = map$2(f, param[0]); + var d$prime = Caml_curry.app1(f, param[2]); + var r$prime = map$2(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: param[1], + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -1950,18 +1907,19 @@ function map$2(f, param) { function mapi$2(f, param) { if (param) { - var v = param[2]; - var l$prime = mapi$2(f, param[1]); - var d$prime = Caml_curry.app2(f, v, param[3]); - var r$prime = mapi$2(f, param[4]); - return [ - /* Node */0, - l$prime, - v, - d$prime, - r$prime, - param[5] - ]; + var v = param[1]; + var l$prime = mapi$2(f, param[0]); + var d$prime = Caml_curry.app2(f, v, param[2]); + var r$prime = mapi$2(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: v, + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -1973,8 +1931,8 @@ function fold$2(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold$2(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold$2(f, m[0], accu)); + _m = m[3]; continue ; } @@ -1988,9 +1946,9 @@ function for_all$2(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { - if (for_all$2(p, param[1])) { - _param = param[4]; + if (Caml_curry.app2(p, param[1], param[2])) { + if (for_all$2(p, param[0])) { + _param = param[3]; continue ; } @@ -2012,14 +1970,14 @@ function exists$2(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { + if (Caml_curry.app2(p, param[1], param[2])) { return /* true */1; } - else if (exists$2(p, param[1])) { + else if (exists$2(p, param[0])) { return /* true */1; } else { - _param = param[4]; + _param = param[3]; continue ; } @@ -2032,7 +1990,7 @@ function exists$2(p, _param) { function add_min_binding$2(k, v, param) { if (param) { - return bal$2(add_min_binding$2(k, v, param[1]), param[2], param[3], param[4]); + return bal$2(add_min_binding$2(k, v, param[0]), param[1], param[2], param[3]); } else { return singleton$2(k, v); @@ -2041,7 +1999,7 @@ function add_min_binding$2(k, v, param) { function add_max_binding$2(k, v, param) { if (param) { - return bal$2(param[1], param[2], param[3], add_max_binding$2(k, v, param[4])); + return bal$2(param[0], param[1], param[2], add_max_binding$2(k, v, param[3])); } else { return singleton$2(k, v); @@ -2051,13 +2009,13 @@ function add_max_binding$2(k, v, param) { function join$2(l, v, d, r) { if (l) { if (r) { - var rh = r[5]; - var lh = l[5]; + var rh = r[4]; + var lh = l[4]; if (lh > rh + 2) { - return bal$2(l[1], l[2], l[3], join$2(l[4], v, d, r)); + return bal$2(l[0], l[1], l[2], join$2(l[3], v, d, r)); } else if (rh > lh + 2) { - return bal$2(join$2(l, v, d, r[1]), r[2], r[3], r[4]); + return bal$2(join$2(l, v, d, r[0]), r[1], r[2], r[3]); } else { return create$2(l, v, d, r); @@ -2076,7 +2034,7 @@ function concat$2(t1, t2) { if (t1) { if (t2) { var match = min_binding$2(t2); - return join$2(t1, match[1], match[2], remove_min_binding$2(t2)); + return join$2(t1, match[0], match[1], remove_min_binding$2(t2)); } else { return t1; @@ -2089,7 +2047,7 @@ function concat$2(t1, t2) { function concat_or_join$2(t1, v, d, t2) { if (d) { - return join$2(t1, v, d[1], t2); + return join$2(t1, v, d[0], t2); } else { return concat$2(t1, t2); @@ -2098,46 +2056,39 @@ function concat_or_join$2(t1, v, d, t2) { function split$2(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { var match = split$2(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join$2(match[3], v, d, r) + join$2(match[2], v, d, r) ]; } else { var match$1 = split$2(x, r); - return [ - /* tuple */0, - join$2(l, v, d, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join$2(l, v, d, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, - [ - /* Some */0, - d - ], + /* Some */[d], r ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* None */0, /* Empty */0 @@ -2148,13 +2099,10 @@ function split$2(x, param) { function merge$2(f, s1, s2) { var exit = 0; if (s1) { - var v1 = s1[2]; - if (s1[5] >= height$2(s2)) { + var v1 = s1[1]; + if (s1[4] >= height$2(s2)) { var match = split$2(v1, s2); - return concat_or_join$2(merge$2(f, s1[1], match[1]), v1, Caml_curry.app3(f, v1, [ - /* Some */0, - s1[3] - ], match[2]), merge$2(f, s1[4], match[3])); + return concat_or_join$2(merge$2(f, s1[0], match[0]), v1, Caml_curry.app3(f, v1, /* Some */[s1[2]], match[1]), merge$2(f, s1[3], match[2])); } else { exit = 1; @@ -2168,19 +2116,14 @@ function merge$2(f, s1, s2) { } if (exit === 1) { if (s2) { - var v2 = s2[2]; + var v2 = s2[1]; var match$1 = split$2(v2, s1); - return concat_or_join$2(merge$2(f, match$1[1], s2[1]), v2, Caml_curry.app3(f, v2, match$1[2], [ - /* Some */0, - s2[3] - ]), merge$2(f, match$1[3], s2[4])); + return concat_or_join$2(merge$2(f, match$1[0], s2[0]), v2, Caml_curry.app3(f, v2, match$1[1], /* Some */[s2[2]]), merge$2(f, match$1[2], s2[3])); } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map.ml", 270, 10 @@ -2193,11 +2136,11 @@ function merge$2(f, s1, s2) { function filter$2(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var l$prime = filter$2(p, param[1]); + var d = param[2]; + var v = param[1]; + var l$prime = filter$2(p, param[0]); var pvd = Caml_curry.app2(p, v, d); - var r$prime = filter$2(p, param[4]); + var r$prime = filter$2(p, param[3]); if (pvd) { return join$2(l$prime, v, d, r$prime); } @@ -2212,33 +2155,30 @@ function filter$2(p, param) { function partition$2(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var match = partition$2(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var d = param[2]; + var v = param[1]; + var match = partition$2(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pvd = Caml_curry.app2(p, v, d); - var match$1 = partition$2(p, param[4]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition$2(p, param[3]); + var rf = match$1[1]; + var rt = match$1[0]; if (pvd) { - return [ - /* tuple */0, + return /* tuple */[ join$2(lt, v, d, rt), concat$2(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat$2(lt, rt), join$2(lf, v, d, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -2250,14 +2190,15 @@ function cons_enum$2(_m, _e) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -2275,18 +2216,18 @@ function compare$2(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_primitive.caml_int_compare(e1[1], e2[1]); + var c = Caml_obj.caml_int_compare(e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum$2(e2[3], e2[4]); - _e1 = cons_enum$2(e1[3], e1[4]); + _e2 = cons_enum$2(e2[2], e2[3]); + _e1 = cons_enum$2(e1[2], e1[3]); continue ; } @@ -2313,10 +2254,10 @@ function equal$2(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - if (e1[1] === e2[1]) { - if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum$2(e2[3], e2[4]); - _e1 = cons_enum$2(e1[3], e1[4]); + if (e1[0] === e2[0]) { + if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum$2(e2[2], e2[3]); + _e1 = cons_enum$2(e1[2], e1[3]); continue ; } @@ -2343,7 +2284,7 @@ function equal$2(cmp, m1, m2) { function cardinal$2(param) { if (param) { - return cardinal$2(param[1]) + 1 + cardinal$2(param[4]); + return cardinal$2(param[0]) + 1 + cardinal$2(param[3]); } else { return 0; @@ -2355,15 +2296,13 @@ function bindings_aux$2(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - [ - /* tuple */0, - param[2], - param[3] + _param = param[0]; + _accu = /* :: */[ + /* tuple */[ + param[1], + param[2] ], - bindings_aux$2(accu, param[4]) + bindings_aux$2(accu, param[3]) ]; continue ; @@ -2379,7 +2318,6 @@ function bindings$2(s) { } var Labs = [ - 0, /* Empty */0, is_empty$2, mem$2, @@ -2406,8 +2344,7 @@ var Labs = [ mapi$2 ]; -var dummy_table = [ - /* record */0, +var dummy_table = /* record */[ 0, /* array */[dummy_item], /* Empty */0, @@ -2418,12 +2355,9 @@ var dummy_table = [ /* [] */0 ]; -var table_count = [ - 0, - 0 -]; +var table_count = [0]; -var dummy_met = [0]; +var dummy_met = []; function fit_size(n) { if (n <= 2) { @@ -2435,7 +2369,7 @@ function fit_size(n) { } function new_table(pub_labels) { - ++ table_count[1]; + ++ table_count[0]; var len = pub_labels.length; var methods = Caml_array.caml_make_vect(len * 2 + 2, dummy_met); methods[0] = len; @@ -2443,8 +2377,7 @@ function new_table(pub_labels) { for(var i = 0 ,i_finish = len - 1; i<= i_finish; ++i){ methods[i * 2 + 3] = pub_labels[i]; } - return [ - /* record */0, + return /* record */[ initial_object_size, methods, /* Empty */0, @@ -2457,11 +2390,11 @@ function new_table(pub_labels) { } function resize(array, new_size) { - var old_size = array[2].length; + var old_size = array[1].length; if (new_size > old_size) { var new_buck = Caml_array.caml_make_vect(new_size, dummy_met); - $$Array.blit(array[2], 0, new_buck, 0, old_size); - array[2] = new_buck; + $$Array.blit(array[1], 0, new_buck, 0, old_size); + array[1] = new_buck; return /* () */0; } else { @@ -2471,35 +2404,29 @@ function resize(array, new_size) { function put(array, label, element) { resize(array, label + 1); - array[2][label] = element; + array[1][label] = element; return /* () */0; } -var method_count = [ - 0, - 0 -]; +var method_count = [0]; -var inst_var_count = [ - 0, - 0 -]; +var inst_var_count = [0]; function new_method(table) { - var index = table[2].length; + var index = table[1].length; resize(table, index + 1); return index; } function get_method_label(table, name) { try { - return find$1(name, table[3]); + return find$1(name, table[2]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { var label = new_method(table); - table[3] = add$1(name, label, table[3]); - table[4] = add$2(label, /* true */1, table[4]); + table[2] = add$1(name, label, table[2]); + table[3] = add$2(label, /* true */1, table[3]); return label; } else { @@ -2515,19 +2442,17 @@ function get_method_labels(table, names) { } function set_method(table, label, element) { - ++ method_count[1]; - if (find$2(label, table[4])) { + ++ method_count[0]; + if (find$2(label, table[3])) { return put(table, label, element); } else { - table[6] = [ - /* :: */0, - [ - /* tuple */0, + table[5] = /* :: */[ + /* tuple */[ label, element ], - table[6] + table[5] ]; return /* () */0; } @@ -2535,11 +2460,11 @@ function set_method(table, label, element) { function get_method(table, label) { try { - return List.assoc(label, table[6]); + return List.assoc(label, table[5]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - return table[2][label]; + return table[1][label]; } else { throw exn; @@ -2566,40 +2491,32 @@ function narrow(table, vars, virt_meths, concr_meths) { var concr_meth_labs = List.map(function (param) { return get_method_label(table, param); }, concr_meths$1); - table[5] = [ - /* :: */0, - [ - /* tuple */0, + table[4] = /* :: */[ + /* tuple */[ + table[2], table[3], - table[4], + table[5], table[6], - table[7], virt_meth_labs, vars$1 ], - table[5] + table[4] ]; - table[7] = fold(function (lab, info, tvars) { + table[6] = fold(function (lab, info, tvars) { if (List.mem(lab, vars$1)) { return add(lab, info, tvars); } else { return tvars; } - }, table[7], /* Empty */0); - var by_name = [ - 0, - /* Empty */0 - ]; - var by_label = [ - 0, - /* Empty */0 - ]; + }, table[6], /* Empty */0); + var by_name = [/* Empty */0]; + var by_label = [/* Empty */0]; List.iter2(function (met, label) { - by_name[1] = add$1(met, label, by_name[1]); + by_name[0] = add$1(met, label, by_name[0]); var $js; try { - $js = find$2(label, table[4]); + $js = find$2(label, table[3]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { @@ -2609,70 +2526,68 @@ function narrow(table, vars, virt_meths, concr_meths) { throw exn; } } - by_label[1] = add$2(label, $js, by_label[1]); + by_label[0] = add$2(label, $js, by_label[0]); return /* () */0; }, concr_meths$1, concr_meth_labs); List.iter2(function (met, label) { - by_name[1] = add$1(met, label, by_name[1]); - by_label[1] = add$2(label, /* false */0, by_label[1]); + by_name[0] = add$1(met, label, by_name[0]); + by_label[0] = add$2(label, /* false */0, by_label[0]); return /* () */0; }, virt_meths$1, virt_meth_labs); - table[3] = by_name[1]; - table[4] = by_label[1]; - table[6] = List.fold_right(function (met, hm) { - if (List.mem(met[1], virt_meth_labs)) { + table[2] = by_name[0]; + table[3] = by_label[0]; + table[5] = List.fold_right(function (met, hm) { + if (List.mem(met[0], virt_meth_labs)) { return hm; } else { - return [ - /* :: */0, + return /* :: */[ met, hm ]; } - }, table[6], /* [] */0); + }, table[5], /* [] */0); return /* () */0; } function widen(table) { - var match = List.hd(table[5]); - var virt_meths = match[5]; - table[5] = List.tl(table[5]); - table[7] = List.fold_left(function (s, v) { - return add(v, find(v, table[7]), s); - }, match[4], match[6]); + var match = List.hd(table[4]); + var virt_meths = match[4]; + table[4] = List.tl(table[4]); + table[6] = List.fold_left(function (s, v) { + return add(v, find(v, table[6]), s); + }, match[3], match[5]); + table[2] = match[0]; table[3] = match[1]; - table[4] = match[2]; - table[6] = List.fold_right(function (met, hm) { - if (List.mem(met[1], virt_meths)) { + table[5] = List.fold_right(function (met, hm) { + if (List.mem(met[0], virt_meths)) { return hm; } else { - return [ - /* :: */0, + return /* :: */[ met, hm ]; } - }, table[6], match[3]); + }, table[5], match[2]); return /* () */0; } function new_slot(table) { - var index = table[1]; - table[1] = index + 1; + var index = table[0]; + table[0] = index + 1; return index; } function new_variable(table, name) { try { - return find(name, table[7]); + return find(name, table[6]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { var index = new_slot(table); if (name !== "") { - table[7] = add(name, index, table[7]); + table[6] = add(name, index, table[6]); } return index; } @@ -2683,7 +2598,7 @@ function new_variable(table, name) { } function to_array(arr) { - if (Caml_primitive.caml_equal(arr, 0)) { + if (Caml_obj.caml_equal(arr, 0)) { return /* array */[]; } else { @@ -2707,15 +2622,13 @@ function new_methods_variables(table, meths, vals) { function get_variable(table, name) { try { - return find(name, table[7]); + return find(name, table[6]); } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_internalOO.ml", 280, 50 @@ -2735,10 +2648,9 @@ function get_variables(table, names) { } function add_initializer(table, f) { - table[8] = [ - /* :: */0, + table[7] = /* :: */[ f, - table[8] + table[7] ]; return /* () */0; } @@ -2749,8 +2661,8 @@ function create_table(public_methods) { var table = new_table(tags); $$Array.iteri(function (i, met) { var lab = i * 2 + 2; - table[3] = add$1(met, lab, table[3]); - table[4] = add$2(lab, /* true */1, table[4]); + table[2] = add$1(met, lab, table[2]); + table[3] = add$2(lab, /* true */1, table[3]); return /* () */0; }, public_methods); return table; @@ -2761,26 +2673,23 @@ function create_table(public_methods) { } function init_class(table) { - inst_var_count[1] = inst_var_count[1] + table[1] - 1; - table[8] = List.rev(table[8]); - return resize(table, 3 + (table[2][1] * 16 / Sys.word_size | 0)); + inst_var_count[0] = inst_var_count[0] + table[0] - 1; + table[7] = List.rev(table[7]); + return resize(table, 3 + (table[1][1] * 16 / Sys.word_size | 0)); } function inherits(cla, vals, virt_meths, concr_meths, param, top) { - var $$super = param[2]; + var $$super = param[1]; narrow(cla, vals, virt_meths, concr_meths); - var init = top ? Caml_curry.app2($$super, cla, param[4]) : Caml_curry.app1($$super, cla); + var init = top ? Caml_curry.app2($$super, cla, param[3]) : Caml_curry.app1($$super, cla); widen(cla); - return Caml_array.caml_array_concat([ - /* :: */0, + return Caml_array.caml_array_concat(/* :: */[ /* array */[init], - [ - /* :: */0, + /* :: */[ $$Array.map(function (param) { return get_variable(cla, param); }, to_array(vals)), - [ - /* :: */0, + /* :: */[ $$Array.map(function (nm) { return get_method(cla, get_method_label(cla, nm)); }, to_array(concr_meths)), @@ -2794,8 +2703,7 @@ function make_class(pub_meths, class_init) { var table = create_table(pub_meths); var env_init = Caml_curry.app1(class_init, table); init_class(table); - return [ - /* tuple */0, + return /* tuple */[ Caml_curry.app1(env_init, 0), class_init, env_init, @@ -2807,21 +2715,19 @@ function make_class_store(pub_meths, class_init, init_table) { var table = create_table(pub_meths); var env_init = Caml_curry.app1(class_init, table); init_class(table); - init_table[2] = class_init; - init_table[1] = env_init; + init_table[1] = class_init; + init_table[0] = env_init; return /* () */0; } function dummy_class(loc) { var undef = function () { throw [ - 0, Caml_builtin_exceptions.Undefined_recursive_module, loc ]; }; - return [ - /* tuple */0, + return /* tuple */[ undef, undef, undef, @@ -2830,8 +2736,11 @@ function dummy_class(loc) { } function create_object(table) { - var obj = Object.defineProperty(Caml_obj_runtime.caml_obj_block(Obj.object_tag, table[1]), "##ml",{"value" : true, "writable" : false}); - obj[0] = table[2]; + var obj = { + length: table[0], + tag: Obj.object_tag + }; + obj[0] = table[1]; return Caml_builtin_exceptions.caml_set_oo_id(obj); } @@ -2840,8 +2749,11 @@ function create_object_opt(obj_0, table) { return obj_0; } else { - var obj = Object.defineProperty(Caml_obj_runtime.caml_obj_block(Obj.object_tag, table[1]), "##ml",{"value" : true, "writable" : false}); - obj[0] = table[2]; + var obj = { + length: table[0], + tag: Obj.object_tag + }; + obj[0] = table[1]; return Caml_builtin_exceptions.caml_set_oo_id(obj); } } @@ -2850,8 +2762,8 @@ function iter_f(obj, _param) { while(true) { var param = _param; if (param) { - Caml_curry.app1(param[1], obj); - _param = param[2]; + Caml_curry.app1(param[0], obj); + _param = param[1]; continue ; } @@ -2862,7 +2774,7 @@ function iter_f(obj, _param) { } function run_initializers(obj, table) { - var inits = table[8]; + var inits = table[7]; if (inits !== /* [] */0) { return iter_f(obj, inits); } @@ -2876,7 +2788,7 @@ function run_initializers_opt(obj_0, obj, table) { return obj; } else { - var inits = table[8]; + var inits = table[7]; if (inits !== /* [] */0) { iter_f(obj, inits); } @@ -2896,22 +2808,22 @@ function create_object_and_run_initializers(obj_0, table) { } function build_path(n, keys, tables) { - var res = [ - /* record */0, + var res = /* record */[ 0, /* Empty */0, /* Empty */0 ]; var r = res; for(var i = 0; i<= n; ++i){ - r = [ - /* Cons */0, - keys[i], - r, - /* Empty */0 - ]; + r = /* Cons */{ + 0: keys[i], + 1: r, + 2: /* Empty */0, + length: 3, + tag: 0 + }; } - tables[2] = r; + tables[1] = r; return res; } @@ -2924,22 +2836,23 @@ function lookup_keys(i, keys, tables) { var _tables = tables; while(true) { var tables$1 = _tables; - if (tables$1[1] === key) { - return lookup_keys(i - 1, keys, tables$1[2]); + if (tables$1[0] === key) { + return lookup_keys(i - 1, keys, tables$1[1]); } - else if (tables$1[3] !== /* Empty */0) { - _tables = tables$1[3]; + else if (tables$1[2] !== /* Empty */0) { + _tables = tables$1[2]; continue ; } else { - var next = [ - /* Cons */0, - key, - /* Empty */0, - /* Empty */0 - ]; - tables$1[3] = next; + var next = /* Cons */{ + 0: key, + 1: /* Empty */0, + 2: /* Empty */0, + length: 3, + tag: 0 + }; + tables$1[2] = next; return build_path(i - 1, keys, next); } }; @@ -2947,8 +2860,8 @@ function lookup_keys(i, keys, tables) { } function lookup_tables(root, keys) { - if (root[2] !== /* Empty */0) { - return lookup_keys(keys.length - 1, keys, root[2]); + if (root[1] !== /* Empty */0) { + return lookup_keys(keys.length - 1, keys, root[1]); } else { return build_path(keys.length - 1, keys, root); @@ -2975,7 +2888,7 @@ function get_env(e, n) { function get_meth(n) { return function (obj) { - return Caml_curry.app1(obj[1][n], obj); + return Caml_curry.app1(obj[0][n], obj); }; } @@ -3006,7 +2919,7 @@ function app_env(f, e, n) { function app_meth(f, n) { return function (obj) { - return Caml_curry.app1(f, Caml_curry.app1(obj[1][n], obj)); + return Caml_curry.app1(f, Caml_curry.app1(obj[0][n], obj)); }; } @@ -3024,7 +2937,7 @@ function app_const_var(f, x, n) { function app_const_meth(f, x, n) { return function (obj) { - return Caml_curry.app2(f, x, Caml_curry.app1(obj[1][n], obj)); + return Caml_curry.app2(f, x, Caml_curry.app1(obj[0][n], obj)); }; } @@ -3036,7 +2949,7 @@ function app_var_const(f, n, x) { function app_meth_const(f, n, x) { return function (obj) { - return Caml_curry.app2(f, Caml_curry.app1(obj[1][n], obj), x); + return Caml_curry.app2(f, Caml_curry.app1(obj[0][n], obj), x); }; } @@ -3054,25 +2967,25 @@ function app_env_const(f, e, n, x) { function meth_app_const(n, x) { return function (obj) { - return Caml_curry.app2(obj[1][n], obj, x); + return Caml_curry.app2(obj[0][n], obj, x); }; } function meth_app_var(n, m) { return function (obj) { - return Caml_curry.app2(obj[1][n], obj, obj[m]); + return Caml_curry.app2(obj[0][n], obj, obj[m]); }; } function meth_app_env(n, e, m) { return function (obj) { - return Caml_curry.app2(obj[1][n], obj, obj[e][m]); + return Caml_curry.app2(obj[0][n], obj, obj[e][m]); }; } function meth_app_meth(n, m) { return function (obj) { - return Caml_curry.app2(obj[1][n], obj, Caml_curry.app1(obj[1][m], obj)); + return Caml_curry.app2(obj[0][n], obj, Caml_curry.app1(obj[0][m], obj)); }; } @@ -3096,21 +3009,21 @@ function send_env(m, e, n, _) { function send_meth(m, n, _) { return function (obj) { - return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, Caml_curry.app1(obj[1][n], obj), m, 4), Caml_curry.app1(obj[1][n], obj)); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, Caml_curry.app1(obj[0][n], obj), m, 4), Caml_curry.app1(obj[0][n], obj)); }; } function new_cache(table) { var n = new_method(table); - var n$1 = n % 2 === 0 || n > 2 + (table[2][1] * 16 / Sys.word_size | 0) ? n : new_method(table); - table[2][n$1] = 0; + var n$1 = n % 2 === 0 || n > 2 + (table[1][1] * 16 / Sys.word_size | 0) ? n : new_method(table); + table[1][n$1] = 0; return n$1; } function method_impl(table, i, arr) { var next = function () { - ++ i[1]; - return arr[i[1]]; + ++ i[0]; + return arr[i[0]]; }; var clo = next(/* () */0); if (typeof clo === "number") { @@ -3241,25 +3154,21 @@ function method_impl(table, i, arr) { function set_methods(table, methods) { var len = methods.length; - var i = [ - 0, - 0 - ]; - while(i[1] < len) { - var label = methods[i[1]]; + var i = [0]; + while(i[0] < len) { + var label = methods[i[0]]; var clo = method_impl(table, i, methods); set_method(table, label, clo); - ++ i[1]; + ++ i[0]; }; return /* () */0; } function stats() { - return [ - /* record */0, - table_count[1], - method_count[1], - inst_var_count[1] + return /* record */[ + table_count[0], + method_count[0], + inst_var_count[0] ]; } diff --git a/jscomp/test/test_js_ffi.js b/jscomp/test/test_js_ffi.js index 99c55b7578..22cd8ad604 100644 --- a/jscomp/test/test_js_ffi.js +++ b/jscomp/test/test_js_ffi.js @@ -4,10 +4,7 @@ var $$String = require("../stdlib/string"); function v() { - return t([ - 0, - $$String.compare - ]); + return t([$$String.compare]); } function u(v) { @@ -15,7 +12,6 @@ function u(v) { } var s = [ - 0, $$String.make, $$String.init, $$String.copy, diff --git a/jscomp/test/test_list.js b/jscomp/test/test_list.js index b77026171f..a421f3c327 100644 --- a/jscomp/test/test_list.js +++ b/jscomp/test/test_list.js @@ -2,8 +2,8 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("../stdlib/pervasives"); -var Caml_primitive = require("../runtime/caml_primitive"); var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); @@ -12,7 +12,7 @@ function length_aux(_len, _param) { var param = _param; var len = _len; if (param) { - _param = param[2]; + _param = param[1]; _len = len + 1; continue ; @@ -29,11 +29,10 @@ function length(l) { function hd(param) { if (param) { - return param[1]; + return param[0]; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "hd" ]; @@ -42,11 +41,10 @@ function hd(param) { function tl(param) { if (param) { - return param[2]; + return param[1]; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "tl" ]; @@ -56,7 +54,6 @@ function tl(param) { function nth(l, n) { if (n < 0) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.nth" ]; @@ -70,17 +67,16 @@ function nth(l, n) { if (l$1) { if (n$1) { _n = n$1 - 1; - _l = l$1[2]; + _l = l$1[1]; continue ; } else { - return l$1[1]; + return l$1[0]; } } else { throw [ - 0, Caml_builtin_exceptions.Failure, "nth" ]; @@ -94,12 +90,11 @@ function rev_append(_l1, _l2) { var l2 = _l2; var l1 = _l1; if (l1) { - _l2 = [ - /* :: */0, - l1[1], + _l2 = /* :: */[ + l1[0], l2 ]; - _l1 = l1[2]; + _l1 = l1[1]; continue ; } @@ -115,7 +110,7 @@ function rev(l) { function flatten(param) { if (param) { - return Pervasives.$at(param[1], flatten(param[2])); + return Pervasives.$at(param[0], flatten(param[1])); } else { return /* [] */0; @@ -124,11 +119,10 @@ function flatten(param) { function map(f, param) { if (param) { - var r = Caml_curry.app1(f, param[1]); - return [ - /* :: */0, + var r = Caml_curry.app1(f, param[0]); + return /* :: */[ r, - map(f, param[2]) + map(f, param[1]) ]; } else { @@ -138,11 +132,10 @@ function map(f, param) { function mapi(i, f, param) { if (param) { - var r = Caml_curry.app2(f, i, param[1]); - return [ - /* :: */0, + var r = Caml_curry.app2(f, i, param[0]); + return /* :: */[ r, - mapi(i + 1, f, param[2]) + mapi(i + 1, f, param[1]) ]; } else { @@ -161,10 +154,9 @@ function rev_map(f, l) { var param = _param; var accu = _accu; if (param) { - _param = param[2]; - _accu = [ - /* :: */0, - Caml_curry.app1(f, param[1]), + _param = param[1]; + _accu = /* :: */[ + Caml_curry.app1(f, param[0]), accu ]; continue ; @@ -180,8 +172,8 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - Caml_curry.app1(f, param[1]); - _param = param[2]; + Caml_curry.app1(f, param[0]); + _param = param[1]; continue ; } @@ -199,8 +191,8 @@ function iteri(f, l) { var param = _param; var i = _i; if (param) { - Caml_curry.app2(f$1, i, param[1]); - _param = param[2]; + Caml_curry.app2(f$1, i, param[0]); + _param = param[1]; _i = i + 1; continue ; @@ -216,8 +208,8 @@ function fold_left(f, _accu, _l) { var l = _l; var accu = _accu; if (l) { - _l = l[2]; - _accu = Caml_curry.app2(f, accu, l[1]); + _l = l[1]; + _accu = Caml_curry.app2(f, accu, l[0]); continue ; } @@ -229,7 +221,7 @@ function fold_left(f, _accu, _l) { function fold_right(f, l, accu) { if (l) { - return Caml_curry.app2(f, l[1], fold_right(f, l[2], accu)); + return Caml_curry.app2(f, l[0], fold_right(f, l[1], accu)); } else { return accu; @@ -239,16 +231,14 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - var r = Caml_curry.app2(f, l1[1], l2[1]); - return [ - /* :: */0, + var r = Caml_curry.app2(f, l1[0], l2[0]); + return /* :: */[ r, - map2(f, l1[2], l2[2]) + map2(f, l1[1], l2[1]) ]; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.map2" ]; @@ -256,7 +246,6 @@ function map2(f, l1, l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.map2" ]; @@ -276,11 +265,10 @@ function rev_map2(f, l1, l2) { var accu = _accu; if (l1$1) { if (l2$1) { - _l2 = l2$1[2]; - _l1 = l1$1[2]; - _accu = [ - /* :: */0, - Caml_curry.app2(f, l1$1[1], l2$1[1]), + _l2 = l2$1[1]; + _l1 = l1$1[1]; + _accu = /* :: */[ + Caml_curry.app2(f, l1$1[0], l2$1[0]), accu ]; continue ; @@ -288,7 +276,6 @@ function rev_map2(f, l1, l2) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.rev_map2" ]; @@ -296,7 +283,6 @@ function rev_map2(f, l1, l2) { } else if (l2$1) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.rev_map2" ]; @@ -313,15 +299,14 @@ function iter2(f, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - Caml_curry.app2(f, l1[1], l2[1]); - _l2 = l2[2]; - _l1 = l1[2]; + Caml_curry.app2(f, l1[0], l2[0]); + _l2 = l2[1]; + _l1 = l1[1]; continue ; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.iter2" ]; @@ -329,7 +314,6 @@ function iter2(f, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.iter2" ]; @@ -347,15 +331,14 @@ function fold_left2(f, _accu, _l1, _l2) { var accu = _accu; if (l1) { if (l2) { - _l2 = l2[2]; - _l1 = l1[2]; - _accu = Caml_curry.app3(f, accu, l1[1], l2[1]); + _l2 = l2[1]; + _l1 = l1[1]; + _accu = Caml_curry.app3(f, accu, l1[0], l2[0]); continue ; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_left2" ]; @@ -363,7 +346,6 @@ function fold_left2(f, _accu, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_left2" ]; @@ -377,11 +359,10 @@ function fold_left2(f, _accu, _l1, _l2) { function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return Caml_curry.app3(f, l1[1], l2[1], fold_right2(f, l1[2], l2[2], accu)); + return Caml_curry.app3(f, l1[0], l2[0], fold_right2(f, l1[1], l2[1], accu)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_right2" ]; @@ -389,7 +370,6 @@ function fold_right2(f, l1, l2, accu) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.fold_right2" ]; @@ -403,8 +383,8 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[1])) { - _param = param[2]; + if (Caml_curry.app1(p, param[0])) { + _param = param[1]; continue ; } @@ -422,11 +402,11 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[1])) { + if (Caml_curry.app1(p, param[0])) { return /* true */1; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -443,9 +423,9 @@ function for_all2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (Caml_curry.app2(p, l1[1], l2[1])) { - _l2 = l2[2]; - _l1 = l1[2]; + if (Caml_curry.app2(p, l1[0], l2[0])) { + _l2 = l2[1]; + _l1 = l1[1]; continue ; } @@ -455,7 +435,6 @@ function for_all2(p, _l1, _l2) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.for_all2" ]; @@ -463,7 +442,6 @@ function for_all2(p, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.for_all2" ]; @@ -480,19 +458,18 @@ function exists2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (Caml_curry.app2(p, l1[1], l2[1])) { + if (Caml_curry.app2(p, l1[0], l2[0])) { return /* true */1; } else { - _l2 = l2[2]; - _l1 = l1[2]; + _l2 = l2[1]; + _l1 = l1[1]; continue ; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.exists2" ]; @@ -500,7 +477,6 @@ function exists2(p, _l1, _l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.exists2" ]; @@ -515,8 +491,8 @@ function mem(x, _param) { while(true) { var param = _param; if (param) { - if (Caml_primitive.caml_compare(param[1], x)) { - _param = param[2]; + if (Caml_obj.caml_compare(param[0], x)) { + _param = param[1]; continue ; } @@ -534,11 +510,11 @@ function memq(x, _param) { while(true) { var param = _param; if (param) { - if (param[1] === x) { + if (param[0] === x) { return /* true */1; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -553,14 +529,14 @@ function assoc(x, _param) { while(true) { var param = _param; if (param) { - var match = param[1]; - if (Caml_primitive.caml_compare(match[1], x)) { - _param = param[2]; + var match = param[0]; + if (Caml_obj.caml_compare(match[0], x)) { + _param = param[1]; continue ; } else { - return match[2]; + return match[1]; } } else { @@ -573,12 +549,12 @@ function assq(x, _param) { while(true) { var param = _param; if (param) { - var match = param[1]; - if (match[1] === x) { - return match[2]; + var match = param[0]; + if (match[0] === x) { + return match[1]; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -593,8 +569,8 @@ function mem_assoc(x, _param) { while(true) { var param = _param; if (param) { - if (Caml_primitive.caml_compare(param[1][1], x)) { - _param = param[2]; + if (Caml_obj.caml_compare(param[0][0], x)) { + _param = param[1]; continue ; } @@ -612,11 +588,11 @@ function mem_assq(x, _param) { while(true) { var param = _param; if (param) { - if (param[1][1] === x) { + if (param[0][0] === x) { return /* true */1; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -629,11 +605,10 @@ function mem_assq(x, _param) { function remove_assoc(x, param) { if (param) { - var l = param[2]; - var pair = param[1]; - if (Caml_primitive.caml_compare(pair[1], x)) { - return [ - /* :: */0, + var l = param[1]; + var pair = param[0]; + if (Caml_obj.caml_compare(pair[0], x)) { + return /* :: */[ pair, remove_assoc(x, l) ]; @@ -649,14 +624,13 @@ function remove_assoc(x, param) { function remove_assq(x, param) { if (param) { - var l = param[2]; - var pair = param[1]; - if (pair[1] === x) { + var l = param[1]; + var pair = param[0]; + if (pair[0] === x) { return l; } else { - return [ - /* :: */0, + return /* :: */[ pair, remove_assq(x, l) ]; @@ -671,12 +645,12 @@ function find(p, _param) { while(true) { var param = _param; if (param) { - var x = param[1]; + var x = param[0]; if (Caml_curry.app1(p, x)) { return x; } else { - _param = param[2]; + _param = param[1]; continue ; } @@ -695,12 +669,11 @@ function find_all(p) { var param$1 = _param; var accu = _accu; if (param$1) { - var l = param$1[2]; - var x = param$1[1]; + var l = param$1[1]; + var x = param$1[0]; if (Caml_curry.app1(p, x)) { _param = l; - _accu = [ - /* :: */0, + _accu = /* :: */[ x, accu ]; @@ -729,12 +702,11 @@ function partition(p, l) { var no = _no; var yes = _yes; if (param) { - var l$1 = param[2]; - var x = param[1]; + var l$1 = param[1]; + var x = param[0]; if (Caml_curry.app1(p, x)) { _param = l$1; - _yes = [ - /* :: */0, + _yes = /* :: */[ x, yes ]; @@ -743,8 +715,7 @@ function partition(p, l) { } else { _param = l$1; - _no = [ - /* :: */0, + _no = /* :: */[ x, no ]; @@ -753,8 +724,7 @@ function partition(p, l) { } } else { - return [ - /* tuple */0, + return /* tuple */[ rev_append(yes, /* [] */0), rev_append(no, /* [] */0) ]; @@ -764,25 +734,21 @@ function partition(p, l) { function split(param) { if (param) { - var match = param[1]; - var match$1 = split(param[2]); - return [ - /* tuple */0, - [ - /* :: */0, + var match = param[0]; + var match$1 = split(param[1]); + return /* tuple */[ + /* :: */[ + match[0], + match$1[0] + ], + /* :: */[ match[1], match$1[1] - ], - [ - /* :: */0, - match[2], - match$1[2] ] ]; } else { - return [ - /* tuple */0, + return /* tuple */[ /* [] */0, /* [] */0 ]; @@ -792,19 +758,16 @@ function split(param) { function combine(l1, l2) { if (l1) { if (l2) { - return [ - /* :: */0, - [ - /* tuple */0, - l1[1], - l2[1] + return /* :: */[ + /* tuple */[ + l1[0], + l2[0] ], - combine(l1[2], l2[2]) + combine(l1[1], l2[1]) ]; } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.combine" ]; @@ -812,7 +775,6 @@ function combine(l1, l2) { } else if (l2) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "List.combine" ]; @@ -825,20 +787,18 @@ function combine(l1, l2) { function merge(cmp, l1, l2) { if (l1) { if (l2) { - var h2 = l2[1]; - var h1 = l1[1]; + var h2 = l2[0]; + var h1 = l1[0]; if (Caml_curry.app2(cmp, h1, h2) <= 0) { - return [ - /* :: */0, + return /* :: */[ h1, - merge(cmp, l1[2], l2) + merge(cmp, l1[1], l2) ]; } else { - return [ - /* :: */0, + return /* :: */[ h2, - merge(cmp, l1, l2[2]) + merge(cmp, l1, l2[1]) ]; } } @@ -857,17 +817,15 @@ function chop(_k, _l) { var k = _k; if (k) { if (l) { - _l = l[2]; + _l = l[1]; _k = k - 1; continue ; } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_list.ml", 224, 11 @@ -889,23 +847,20 @@ function stable_sort(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; if (Caml_curry.app2(cmp, x1, x2) <= 0) { if (Caml_curry.app2(cmp, x2, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -913,14 +868,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x1, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -928,14 +880,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -944,14 +893,11 @@ function stable_sort(cmp, l) { } } else if (Caml_curry.app2(cmp, x1, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -959,14 +905,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x2, x3) <= 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -974,14 +917,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1002,27 +942,23 @@ function stable_sort(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; if (Caml_curry.app2(cmp, x1$1, x2$1) <= 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1051,25 +987,23 @@ function stable_sort(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var h2 = l2$1[1]; - var h1 = l1[1]; + var h2 = l2$1[0]; + var h1 = l1[0]; if (Caml_curry.app2(cmp, h1, h2) > 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; - _l1 = l1[2]; + _l1 = l1[1]; continue ; } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; - _l2 = l2$1[2]; + _l2 = l2$1[1]; continue ; } @@ -1092,23 +1026,20 @@ function stable_sort(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; if (Caml_curry.app2(cmp, x1, x2) > 0) { if (Caml_curry.app2(cmp, x2, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1116,14 +1047,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x1, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1131,14 +1059,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1147,14 +1072,11 @@ function stable_sort(cmp, l) { } } else if (Caml_curry.app2(cmp, x1, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1162,14 +1084,11 @@ function stable_sort(cmp, l) { ]; } else if (Caml_curry.app2(cmp, x2, x3) > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1177,14 +1096,11 @@ function stable_sort(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1205,27 +1121,23 @@ function stable_sort(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; if (Caml_curry.app2(cmp, x1$1, x2$1) > 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1254,25 +1166,23 @@ function stable_sort(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var h2 = l2$1[1]; - var h1 = l1[1]; + var h2 = l2$1[0]; + var h1 = l1[0]; if (Caml_curry.app2(cmp, h1, h2) <= 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; - _l1 = l1[2]; + _l1 = l1[1]; continue ; } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; - _l2 = l2$1[2]; + _l2 = l2$1[1]; continue ; } @@ -1305,27 +1215,24 @@ function sort_uniq(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c < 0) { var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 < 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1336,14 +1243,11 @@ function sort_uniq(cmp, l) { var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 < 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1351,14 +1255,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1367,11 +1268,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1380,11 +1279,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1395,14 +1292,11 @@ function sort_uniq(cmp, l) { var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 < 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1413,14 +1307,11 @@ function sort_uniq(cmp, l) { var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 < 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1428,14 +1319,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1444,11 +1332,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1457,11 +1343,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1473,22 +1357,18 @@ function sort_uniq(cmp, l) { var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 < 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1496,8 +1376,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, /* [] */0 ]; @@ -1517,29 +1396,25 @@ function sort_uniq(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 < 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1547,8 +1422,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1$1, /* [] */0 ]; @@ -1576,15 +1450,14 @@ function sort_uniq(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var t2 = l2$1[2]; - var h2 = l2$1[1]; - var t1 = l1[2]; - var h1 = l1[1]; + var t2 = l2$1[1]; + var h2 = l2$1[0]; + var t1 = l1[1]; + var h1 = l1[0]; var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 > 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; @@ -1593,8 +1466,7 @@ function sort_uniq(cmp, l) { } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; @@ -1604,8 +1476,7 @@ function sort_uniq(cmp, l) { } } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; @@ -1633,27 +1504,24 @@ function sort_uniq(cmp, l) { exit = 1; } else if (l) { - var match = l[2]; + var match = l[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - var x3 = match$1[1]; - var x2 = match[1]; - var x1 = l[1]; + var x3 = match$1[0]; + var x2 = match[0]; + var x1 = l[0]; var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c > 0) { var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1664,14 +1532,11 @@ function sort_uniq(cmp, l) { var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 > 0) { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1679,14 +1544,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1695,11 +1557,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1708,11 +1568,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1723,14 +1581,11 @@ function sort_uniq(cmp, l) { var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] @@ -1741,14 +1596,11 @@ function sort_uniq(cmp, l) { var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1756,14 +1608,11 @@ function sort_uniq(cmp, l) { ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1772,11 +1621,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1785,11 +1632,9 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x1, /* [] */0 ] @@ -1801,22 +1646,18 @@ function sort_uniq(cmp, l) { var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 > 0) { - return [ - /* :: */0, + return /* :: */[ x2, - [ - /* :: */0, + /* :: */[ x3, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x3, - [ - /* :: */0, + /* :: */[ x2, /* [] */0 ] @@ -1824,8 +1665,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x2, /* [] */0 ]; @@ -1845,29 +1685,25 @@ function sort_uniq(cmp, l) { } } else if (l) { - var match$2 = l[2]; + var match$2 = l[1]; if (match$2) { - var x2$1 = match$2[1]; - var x1$1 = l[1]; + var x2$1 = match$2[0]; + var x1$1 = l[0]; var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 > 0) { - return [ - /* :: */0, + return /* :: */[ x1$1, - [ - /* :: */0, + /* :: */[ x2$1, /* [] */0 ] ]; } else { - return [ - /* :: */0, + return /* :: */[ x2$1, - [ - /* :: */0, + /* :: */[ x1$1, /* [] */0 ] @@ -1875,8 +1711,7 @@ function sort_uniq(cmp, l) { } } else { - return [ - /* :: */0, + return /* :: */[ x1$1, /* [] */0 ]; @@ -1904,15 +1739,14 @@ function sort_uniq(cmp, l) { var l1 = _l1; if (l1) { if (l2$1) { - var t2 = l2$1[2]; - var h2 = l2$1[1]; - var t1 = l1[2]; - var h1 = l1[1]; + var t2 = l2$1[1]; + var h2 = l2$1[0]; + var t1 = l1[1]; + var h1 = l1[0]; var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 < 0) { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; @@ -1921,8 +1755,7 @@ function sort_uniq(cmp, l) { } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h2, accu ]; @@ -1932,8 +1765,7 @@ function sort_uniq(cmp, l) { } } else { - _accu = [ - /* :: */0, + _accu = /* :: */[ h1, accu ]; diff --git a/jscomp/test/test_literal.js b/jscomp/test/test_literal.js index ff922d1e9c..2759063633 100644 --- a/jscomp/test/test_literal.js +++ b/jscomp/test/test_literal.js @@ -3,20 +3,20 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Custom_inline = [ - 248, - "Test_literal.Custom_inline", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Custom_inline = { + 0: "Test_literal.Custom_inline", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; var v = [ - 0, Custom_inline, 1, 2 ]; -var vv = /* array */[ +var vv = /* float array */[ 1, 2, 3 @@ -40,7 +40,7 @@ var long_int_v = /* array */[ 6 ]; -var short_int_v = /* array */[1]; +var short_int_v = /* int array */[1]; var empty = /* array */[]; diff --git a/jscomp/test/test_map_find.js b/jscomp/test/test_map_find.js index d2f70548c0..0853d431bc 100644 --- a/jscomp/test/test_map_find.js +++ b/jscomp/test/test_map_find.js @@ -2,15 +2,15 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Assert = require("assert"); var Mt = require("./mt"); -var Caml_primitive = require("../runtime/caml_primitive"); var List = require("../stdlib/list"); var Caml_string = require("../runtime/caml_string"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -20,34 +20,34 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -55,7 +55,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -63,19 +62,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -83,31 +81,31 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_int_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_int_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -117,25 +115,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -143,14 +143,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_int_compare(x, param[2]); + var c = Caml_obj.caml_int_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -160,32 +160,24 @@ function find(x, _param) { } var m = List.fold_left(function (acc, param) { - return add(param[1], param[2], acc); - }, /* Empty */0, [ - /* :: */0, - [ - /* tuple */0, + return add(param[0], param[1], acc); + }, /* Empty */0, /* :: */[ + /* tuple */[ 10, /* "a" */97 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 3, /* "b" */98 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 7, /* "c" */99 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ 20, /* "d" */100 ], @@ -197,7 +189,7 @@ var m = List.fold_left(function (acc, param) { function height$1(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -207,34 +199,34 @@ function height$1(param) { function create$1(l, x, d, r) { var hl = height$1(l); var hr = height$1(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal$1(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height$1(ll) >= height$1(lr)) { return create$1(ll, lv, ld, create$1(lr, x, d, r)); } else if (lr) { - return create$1(create$1(ll, lv, ld, lr[1]), lr[2], lr[3], create$1(lr[4], x, d, r)); + return create$1(create$1(ll, lv, ld, lr[0]), lr[1], lr[2], create$1(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -242,7 +234,6 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -250,19 +241,18 @@ function bal$1(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height$1(rr) >= height$1(rl)) { return create$1(create$1(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create$1(create$1(l, x, d, rl[1]), rl[2], rl[3], create$1(rl[4], rv, rd, rr)); + return create$1(create$1(l, x, d, rl[0]), rl[1], rl[2], create$1(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -270,30 +260,30 @@ function bal$1(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add$1(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -304,25 +294,27 @@ function add$1(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -330,14 +322,14 @@ function find$1(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -347,32 +339,24 @@ function find$1(x, _param) { } var s = List.fold_left(function (acc, param) { - return add$1(param[1], param[2], acc); - }, /* Empty */0, [ - /* :: */0, - [ - /* tuple */0, + return add$1(param[0], param[1], acc); + }, /* Empty */0, /* :: */[ + /* tuple */[ "10", /* "a" */97 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "3", /* "b" */98 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "7", /* "c" */99 ], - [ - /* :: */0, - [ - /* tuple */0, + /* :: */[ + /* tuple */[ "20", /* "d" */100 ], diff --git a/jscomp/test/test_obj_simple_ffi.js b/jscomp/test/test_obj_simple_ffi.js index 4c3b182f6c..c34786accc 100644 --- a/jscomp/test/test_obj_simple_ffi.js +++ b/jscomp/test/test_obj_simple_ffi.js @@ -18,7 +18,7 @@ var v2 = { }; var v3 = { - "display_name": "display", + "display_name": /* Some */["display"] ? undefined : /* Some */["display"][1], "test": 3, "config": 3, "hi": "ghos" diff --git a/jscomp/test/test_order.js b/jscomp/test/test_order.js index 9235dbba57..2bc67c704c 100644 --- a/jscomp/test/test_order.js +++ b/jscomp/test/test_order.js @@ -1,10 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_obj = require("../runtime/caml_obj"); function compare(x, y) { - return Caml_primitive.caml_int_compare(x, y); + return Caml_obj.caml_int_compare(x, y); } exports.compare = compare; diff --git a/jscomp/test/test_per.js b/jscomp/test/test_per.js index 57d52dbc5f..6bc8c5c8a4 100644 --- a/jscomp/test/test_per.js +++ b/jscomp/test/test_per.js @@ -2,6 +2,7 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Caml_io = require("../runtime/caml_io"); var Caml_float = require("../runtime/caml_float"); var Caml_format = require("../runtime/caml_format"); @@ -12,7 +13,6 @@ var Caml_string = require("../runtime/caml_string"); function failwith(s) { throw [ - 0, Caml_builtin_exceptions.Failure, s ]; @@ -20,20 +20,20 @@ function failwith(s) { function invalid_arg(s) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, s ]; } -var Exit = [ - 248, - "Test_per.Exit", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Exit = { + 0: "Test_per.Exit", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function min(x, y) { - if (Caml_primitive.caml_lessequal(x, y)) { + if (Caml_obj.caml_lessequal(x, y)) { return x; } else { @@ -42,7 +42,7 @@ function min(x, y) { } function max(x, y) { - if (Caml_primitive.caml_greaterequal(x, y)) { + if (Caml_obj.caml_greaterequal(x, y)) { return x; } else { @@ -91,7 +91,6 @@ function $caret(s1, s2) { function char_of_int(n) { if (n < 0 || n > 255) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "char_of_int" ]; @@ -118,7 +117,6 @@ function bool_of_string(param) { return /* true */1; default: throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "bool_of_string" ]; @@ -167,10 +165,9 @@ function string_of_float(f) { function $at(l1, l2) { if (l1) { - return [ - /* :: */0, - l1[1], - $at(l1[2], l2) + return /* :: */[ + l1[0], + $at(l1[1], l2) ]; } else { @@ -189,17 +186,13 @@ function open_out_gen(mode, perm, name) { } function open_out(name) { - return open_out_gen([ - /* :: */0, + return open_out_gen(/* :: */[ /* Open_wronly */1, - [ - /* :: */0, + /* :: */[ /* Open_creat */3, - [ - /* :: */0, + /* :: */[ /* Open_trunc */4, - [ - /* :: */0, + /* :: */[ /* Open_text */7, /* [] */0 ] @@ -209,17 +202,13 @@ function open_out(name) { } function open_out_bin(name) { - return open_out_gen([ - /* :: */0, + return open_out_gen(/* :: */[ /* Open_wronly */1, - [ - /* :: */0, + /* :: */[ /* Open_creat */3, - [ - /* :: */0, + /* :: */[ /* Open_trunc */4, - [ - /* :: */0, + /* :: */[ /* Open_binary */6, /* [] */0 ] @@ -234,12 +223,12 @@ function flush_all() { var param = _param; if (param) { try { - Caml_io.caml_ml_flush(param[1]); + Caml_io.caml_ml_flush(param[0]); } catch (exn){ } - _param = param[2]; + _param = param[1]; continue ; } @@ -260,7 +249,6 @@ function output_string(oc, s) { function output(oc, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "output" ]; @@ -273,7 +261,6 @@ function output(oc, s, ofs, len) { function output_substring(oc, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "output_substring" ]; @@ -312,11 +299,9 @@ function open_in_gen(mode, perm, name) { } function open_in(name) { - return open_in_gen([ - /* :: */0, + return open_in_gen(/* :: */[ /* Open_rdonly */0, - [ - /* :: */0, + /* :: */[ /* Open_text */7, /* [] */0 ] @@ -324,11 +309,9 @@ function open_in(name) { } function open_in_bin(name) { - return open_in_gen([ - /* :: */0, + return open_in_gen(/* :: */[ /* Open_rdonly */0, - [ - /* :: */0, + /* :: */[ /* Open_binary */6, /* [] */0 ] @@ -338,7 +321,6 @@ function open_in_bin(name) { function input(ic, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "input" ]; @@ -373,7 +355,6 @@ function unsafe_really_input(ic, s, _ofs, _len) { function really_input(ic, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > s.length - len) { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "really_input" ]; @@ -395,10 +376,10 @@ function input_line(chan) { var param = _param; var pos = _pos; if (param) { - var hd = param[1]; + var hd = param[0]; var len = hd.length; Caml_string.caml_blit_string(hd, 0, buf, pos - len, len); - _param = param[2]; + _param = param[1]; _pos = pos - len; continue ; @@ -421,8 +402,7 @@ function input_line(chan) { Caml_io.caml_ml_input_char(chan); if (accu) { var len$1 = len + n - 1; - return build_result(Caml_string.caml_create_string(len$1), len$1, [ - /* :: */0, + return build_result(Caml_string.caml_create_string(len$1), len$1, /* :: */[ res, accu ]); @@ -435,8 +415,7 @@ function input_line(chan) { var beg = Caml_string.caml_create_string(-n); Caml_primitive.caml_ml_input(chan, beg, 0, -n); _len = len - n; - _accu = [ - /* :: */0, + _accu = /* :: */[ beg, accu ]; @@ -537,28 +516,26 @@ function read_float() { return Caml_format.caml_float_of_string((Caml_io.caml_ml_flush(stdout), input_line(stdin))); } -var LargeFile = [0]; +var LargeFile = []; function string_of_format(param) { - return param[2]; + return param[1]; } function $caret$caret(param, param$1) { - return [ - /* Format */0, - CamlinternalFormatBasics.concat_fmt(param[1], param$1[1]), - $caret(param[2], $caret("%,", param$1[2])) - ]; + return /* Format */{ + 0: CamlinternalFormatBasics.concat_fmt(param[0], param$1[0]), + 1: $caret(param[1], $caret("%,", param$1[1])), + length: 2, + tag: 0 + }; } -var exit_function = [ - 0, - flush_all -]; +var exit_function = [flush_all]; function at_exit(f) { - var g = exit_function[1]; - exit_function[1] = function () { + var g = exit_function[0]; + exit_function[0] = function () { Caml_curry.app1(f, /* () */0); return Caml_curry.app1(g, /* () */0); }; @@ -566,11 +543,11 @@ function at_exit(f) { } function do_at_exit() { - return Caml_curry.app1(exit_function[1], /* () */0); + return Caml_curry.app1(exit_function[0], /* () */0); } function exit(retcode) { - Caml_curry.app1(exit_function[1], /* () */0); + Caml_curry.app1(exit_function[0], /* () */0); return Caml_primitive.caml_sys_exit(retcode); } diff --git a/jscomp/test/test_pervasive.js b/jscomp/test/test_pervasive.js index 4762cf89fd..296d95df9c 100644 --- a/jscomp/test/test_pervasive.js +++ b/jscomp/test/test_pervasive.js @@ -7,7 +7,6 @@ var List = require("../stdlib/list"); var $at = Pervasives.$at; var Pervasives$1 = [ - 0, List.length, List.hd, List.tl, diff --git a/jscomp/test/test_pervasives2.js b/jscomp/test/test_pervasives2.js index 7bdfba0f97..e7629e4389 100644 --- a/jscomp/test/test_pervasives2.js +++ b/jscomp/test/test_pervasives2.js @@ -10,7 +10,6 @@ var length = List.length; var $at = Pervasives.$at; var List$1 = [ - 0, length, List.hd, List.tl, @@ -146,7 +145,6 @@ var List$1 = [ var $at$1 = Pervasives.$at; var U = [ - 0, Stack.Empty, Stack.create, Stack.push, diff --git a/jscomp/test/test_pervasives3.js b/jscomp/test/test_pervasives3.js index 82562854c3..03b1e61961 100644 --- a/jscomp/test/test_pervasives3.js +++ b/jscomp/test/test_pervasives3.js @@ -7,7 +7,6 @@ var List = require("../stdlib/list"); var $at = Pervasives.$at; var Pervasives$1 = [ - 0, Pervasives.invalid_arg, Pervasives.failwith, Pervasives.Exit, diff --git a/jscomp/test/test_primitive.js b/jscomp/test/test_primitive.js index bc410496a6..bc1734d1df 100644 --- a/jscomp/test/test_primitive.js +++ b/jscomp/test/test_primitive.js @@ -1,14 +1,12 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var CamlinternalLazy = require("../stdlib/camlinternalLazy"); var Pervasives = require("../stdlib/pervasives"); var Caml_curry = require("../runtime/caml_curry"); function a4(prim) { return [ - 0, 'File "test_primitive.ml", line 30, characters 9-19', prim ]; @@ -16,7 +14,6 @@ function a4(prim) { function a5(prim) { return [ - 0, 31, prim ]; @@ -24,9 +21,7 @@ function a5(prim) { function a6(prim) { return [ - 0, [ - 0, "test_primitive.ml", 32, 9, @@ -40,7 +35,7 @@ var test_float = 3; var test_abs = Math.abs(3.0); -var v = /* array */[ +var v = /* float array */[ 1.0, 2.0 ]; @@ -65,7 +60,7 @@ function f2(h, b, _) { v[1] = 3.0; -var unboxed_x = /* array */[ +var unboxed_x = /* float array */[ 0, 0 ]; @@ -80,9 +75,9 @@ function f(x) { } function is_lazy_force(x) { - var tag = Caml_obj_runtime.caml_obj_tag(x); + var tag = x.tag | 0; if (tag === 250) { - return x[1]; + return x[0]; } else if (tag === 246) { return CamlinternalLazy.force_lazy_block(x); @@ -111,8 +106,7 @@ var a2 = 28; var a3 = "Test_primitive"; -var xx = [ - /* tuple */0, +var xx = /* tuple */[ 0, 0 ]; diff --git a/jscomp/test/test_ramification.js b/jscomp/test/test_ramification.js index 8286fd9b03..31851f01fc 100644 --- a/jscomp/test/test_ramification.js +++ b/jscomp/test/test_ramification.js @@ -27,7 +27,7 @@ function ff(x) { function f(x) { var y; - y = x[0] ? 4 : 3; + y = x.tag ? 4 : 3; return y + 32; } @@ -35,7 +35,7 @@ function f2(x) { var v = 0; var y; v = 1; - if (x[0]) { + if (x.tag) { var z = 33; y = z + 4; } @@ -50,7 +50,7 @@ function f3(x) { var v = 0; var y; v = 1; - if (x[0]) { + if (x.tag) { y = 4; } else { diff --git a/jscomp/test/test_react.js b/jscomp/test/test_react.js index 43aeb815be..8488f1a699 100644 --- a/jscomp/test/test_react.js +++ b/jscomp/test/test_react.js @@ -14,9 +14,11 @@ var v = console.log(32); ReactDom.render(React.createClass({ "render": function () { - return React.DOM.div({ - "alt": "pic" - }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!"), React.DOM.h3(null, "type safe!")); + return React.DOM.div(/* Some */[{ + "alt": /* Some */["pic"] ? undefined : /* Some */["pic"][1] + }] ? undefined : /* Some */[{ + "alt": /* Some */["pic"] ? undefined : /* Some */["pic"][1] + }][1], React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!"), React.DOM.h3(null, "type safe!")); } }), document.getElementById("hi")); diff --git a/jscomp/test/test_runtime_encoding.js b/jscomp/test/test_runtime_encoding.js index 11313bb101..76066f2cf0 100644 --- a/jscomp/test/test_runtime_encoding.js +++ b/jscomp/test/test_runtime_encoding.js @@ -3,22 +3,21 @@ function g(x) { - return /* array */[ + return /* float array */[ 3, x ]; } function ff(v, u) { - return [ - /* record */0, + return /* record */[ v, u ]; } function fff(vv, uu) { - return /* array */[ + return /* float array */[ vv, uu ]; @@ -33,7 +32,7 @@ function aa(x) { } function aaa(x) { - return x[1]; + return x[0]; } function aaaa(x) { diff --git a/jscomp/test/test_seq.js b/jscomp/test/test_seq.js index 36094f83e1..fee8945f08 100644 --- a/jscomp/test/test_seq.js +++ b/jscomp/test/test_seq.js @@ -2,38 +2,41 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("../stdlib/pervasives"); -var Caml_primitive = require("../runtime/caml_primitive"); var Caml_curry = require("../runtime/caml_curry"); -var Bad = [ - 248, - "Test_seq.Bad", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Bad = { + 0: "Test_seq.Bad", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; -var Help = [ - 248, - "Test_seq.Help", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Help = { + 0: "Test_seq.Help", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; -var Stop = [ - 248, - "Test_seq.Stop", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Stop = { + 0: "Test_seq.Stop", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function assoc3(x, _l) { while(true) { var l = _l; if (l) { - var match = l[1]; - if (Caml_primitive.caml_equal(match[1], x)) { - return match[2]; + var match = l[0]; + if (Caml_obj.caml_equal(match[0], x)) { + return match[1]; } else { - _l = l[2]; + _l = l[1]; continue ; } @@ -46,12 +49,12 @@ function assoc3(x, _l) { function help_action() { throw [ - 0, Stop, - [ - /* Unknown */0, - "-help" - ] + /* Unknown */{ + 0: "-help", + length: 1, + tag: 0 + } ]; } @@ -72,15 +75,14 @@ function add_help(speclist) { } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - add1 = [ - /* :: */0, - [ - /* tuple */0, + add1 = /* :: */[ + /* tuple */[ "-help", - [ - /* Unit */0, - help_action - ], + /* Unit */{ + 0: help_action, + length: 1, + tag: 0 + }, " Display this list of options" ], /* [] */0 @@ -97,15 +99,14 @@ function add_help(speclist) { } catch (exn$1){ if (exn$1 === Caml_builtin_exceptions.Not_found) { - add2 = [ - /* :: */0, - [ - /* tuple */0, + add2 = /* :: */[ + /* tuple */[ "--help", - [ - /* Unit */0, - help_action - ], + /* Unit */{ + 0: help_action, + length: 1, + tag: 0 + }, " Display this list of options" ], /* [] */0 diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index 1c6001819f..2c2cd73e2f 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -8,40 +8,40 @@ var List = require("../stdlib/list"); function Make(Ord) { var height = function (param) { if (param) { - return param[4]; + return param[3]; } else { return 0; } }; var create = function (l, v, r) { - var hl = l ? l[4] : 0; - var hr = r ? r[4] : 0; - return [ - /* Node */0, - l, - v, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + var hl = l ? l[3] : 0; + var hr = r ? r[3] : 0; + return /* Node */{ + 0: l, + 1: v, + 2: r, + 3: hl >= hr ? hl + 1 : hr + 1, + length: 4, + tag: 0 + }; }; var bal = function (l, v, r) { - var hl = l ? l[4] : 0; - var hr = r ? r[4] : 0; + var hl = l ? l[3] : 0; + var hr = r ? r[3] : 0; if (hl > hr + 2) { if (l) { - var lr = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, create(lr, v, r)); } else if (lr) { - return create(create(ll, lv, lr[1]), lr[2], create(lr[3], v, r)); + return create(create(ll, lv, lr[0]), lr[1], create(lr[2], v, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; @@ -49,7 +49,6 @@ function Make(Ord) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; @@ -57,18 +56,17 @@ function Make(Ord) { } else if (hr > hl + 2) { if (r) { - var rr = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, v, rl), rv, rr); } else if (rl) { - return create(create(l, v, rl[1]), rl[2], create(rl[3], rv, rr)); + return create(create(l, v, rl[0]), rl[1], create(rl[2], rv, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; @@ -76,28 +74,28 @@ function Make(Ord) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.bal" ]; } } else { - return [ - /* Node */0, - l, - v, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: v, + 2: r, + 3: hl >= hr ? hl + 1 : hr + 1, + length: 4, + tag: 0 + }; } }; var add = function (x, t) { if (t) { - var r = t[3]; - var v = t[2]; - var l = t[1]; - var c = Caml_curry.app2(Ord[1], x, v); + var r = t[2]; + var v = t[1]; + var l = t[0]; + var c = Caml_curry.app2(Ord[0], x, v); if (c) { if (c < 0) { return bal(add(x, l), v, r); @@ -111,27 +109,29 @@ function Make(Ord) { } } else { - return [ - /* Node */0, - /* Empty */0, - x, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }; } }; var singleton = function (x) { - return [ - /* Node */0, - /* Empty */0, - x, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }; }; var add_min_element = function (v, param) { if (param) { - return bal(add_min_element(v, param[1]), param[2], param[3]); + return bal(add_min_element(v, param[0]), param[1], param[2]); } else { return singleton(v); @@ -139,7 +139,7 @@ function Make(Ord) { }; var add_max_element = function (v, param) { if (param) { - return bal(param[1], param[2], add_max_element(v, param[3])); + return bal(param[0], param[1], add_max_element(v, param[2])); } else { return singleton(v); @@ -148,13 +148,13 @@ function Make(Ord) { var join = function (l, v, r) { if (l) { if (r) { - var rh = r[4]; - var lh = l[4]; + var rh = r[3]; + var lh = l[3]; if (lh > rh + 2) { - return bal(l[1], l[2], join(l[3], v, r)); + return bal(l[0], l[1], join(l[2], v, r)); } else if (rh > lh + 2) { - return bal(join(l, v, r[1]), r[2], r[3]); + return bal(join(l, v, r[0]), r[1], r[2]); } else { return create(l, v, r); @@ -172,14 +172,14 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return param[2]; + return param[1]; } } else { @@ -191,14 +191,14 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - var r = param[3]; + var r = param[2]; if (r) { _param = r; continue ; } else { - return param[2]; + return param[1]; } } else { @@ -208,17 +208,16 @@ function Make(Ord) { }; var remove_min_elt = function (param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal(remove_min_elt(l), param[2], param[3]); + return bal(remove_min_elt(l), param[1], param[2]); } else { - return param[3]; + return param[2]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Set.remove_min_elt" ]; @@ -252,33 +251,30 @@ function Make(Ord) { }; var split = function (x, param) { if (param) { - var r = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_curry.app2(Ord[1], x, v); + var r = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(Ord[0], x, v); if (c) { if (c < 0) { var match = split(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join(match[3], v, r) + join(match[2], v, r) ]; } else { var match$1 = split(x, r); - return [ - /* tuple */0, - join(l, v, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join(l, v, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, /* true */1, r @@ -286,8 +282,7 @@ function Make(Ord) { } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* false */0, /* Empty */0 @@ -307,9 +302,9 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - var c = Caml_curry.app2(Ord[1], x, param[2]); + var c = Caml_curry.app2(Ord[0], x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[3]; + _param = c < 0 ? param[0] : param[2]; continue ; } @@ -324,10 +319,10 @@ function Make(Ord) { }; var remove = function (x, param) { if (param) { - var r = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_curry.app2(Ord[1], x, v); + var r = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_curry.app2(Ord[0], x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, r); @@ -347,17 +342,17 @@ function Make(Ord) { var union = function (s1, s2) { if (s1) { if (s2) { - var h2 = s2[4]; - var v2 = s2[2]; - var h1 = s1[4]; - var v1 = s1[2]; + var h2 = s2[3]; + var v2 = s2[1]; + var h1 = s1[3]; + var v1 = s1[1]; if (h1 >= h2) { if (h2 === 1) { return add(v2, s1); } else { var match = split(v1, s2); - return join(union(s1[1], match[1]), v1, union(s1[3], match[3])); + return join(union(s1[0], match[0]), v1, union(s1[2], match[2])); } } else if (h1 === 1) { @@ -365,7 +360,7 @@ function Make(Ord) { } else { var match$1 = split(v2, s1); - return join(union(match$1[1], s2[1]), v2, union(match$1[3], s2[3])); + return join(union(match$1[0], s2[0]), v2, union(match$1[2], s2[2])); } } else { @@ -379,16 +374,16 @@ function Make(Ord) { var inter = function (s1, s2) { if (s1) { if (s2) { - var r1 = s1[3]; - var v1 = s1[2]; - var l1 = s1[1]; + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; var match = split(v1, s2); - var l2 = match[1]; - if (match[2] !== 0) { - return join(inter(l1, l2), v1, inter(r1, match[3])); + var l2 = match[0]; + if (match[1] !== 0) { + return join(inter(l1, l2), v1, inter(r1, match[2])); } else { - return concat(inter(l1, l2), inter(r1, match[3])); + return concat(inter(l1, l2), inter(r1, match[2])); } } else { @@ -402,16 +397,16 @@ function Make(Ord) { var diff = function (s1, s2) { if (s1) { if (s2) { - var r1 = s1[3]; - var v1 = s1[2]; - var l1 = s1[1]; + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; var match = split(v1, s2); - var l2 = match[1]; - if (match[2] !== 0) { - return concat(diff(l1, l2), diff(r1, match[3])); + var l2 = match[0]; + if (match[1] !== 0) { + return concat(diff(l1, l2), diff(r1, match[2])); } else { - return join(diff(l1, l2), v1, diff(r1, match[3])); + return join(diff(l1, l2), v1, diff(r1, match[2])); } } else { @@ -427,13 +422,14 @@ function Make(Ord) { var e = _e; var s = _s; if (s) { - _e = [ - /* More */0, - s[2], - s[3], - e - ]; - _s = s[1]; + _e = /* More */{ + 0: s[1], + 1: s[2], + 2: e, + length: 3, + tag: 0 + }; + _s = s[0]; continue ; } @@ -448,13 +444,13 @@ function Make(Ord) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_curry.app2(Ord[1], e1[1], e2[1]); + var c = Caml_curry.app2(Ord[0], e1[0], e2[0]); if (c !== 0) { return c; } else { - _e2 = cons_enum(e2[2], e2[3]); - _e1 = cons_enum(e1[2], e1[3]); + _e2 = cons_enum(e2[1], e2[2]); + _e1 = cons_enum(e1[1], e1[2]); continue ; } @@ -483,21 +479,22 @@ function Make(Ord) { var s1 = _s1; if (s1) { if (s2) { - var r2 = s2[3]; - var l2 = s2[1]; - var r1 = s1[3]; - var v1 = s1[2]; - var l1 = s1[1]; - var c = Caml_curry.app2(Ord[1], v1, s2[2]); + var r2 = s2[2]; + var l2 = s2[0]; + var r1 = s1[2]; + var v1 = s1[1]; + var l1 = s1[0]; + var c = Caml_curry.app2(Ord[0], v1, s2[1]); if (c) { if (c < 0) { - if (subset([ - /* Node */0, - l1, - v1, - /* Empty */0, - 0 - ], l2)) { + if (subset(/* Node */{ + 0: l1, + 1: v1, + 2: /* Empty */0, + 3: 0, + length: 4, + tag: 0 + }, l2)) { _s1 = r1; continue ; @@ -506,13 +503,14 @@ function Make(Ord) { return /* false */0; } } - else if (subset([ - /* Node */0, - /* Empty */0, - v1, - r1, - 0 - ], r2)) { + else if (subset(/* Node */{ + 0: /* Empty */0, + 1: v1, + 2: r1, + 3: 0, + length: 4, + tag: 0 + }, r2)) { _s1 = l1; continue ; @@ -544,9 +542,9 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - iter(f, param[1]); - Caml_curry.app1(f, param[2]); - _param = param[3]; + iter(f, param[0]); + Caml_curry.app1(f, param[1]); + _param = param[2]; continue ; } @@ -560,8 +558,8 @@ function Make(Ord) { var accu = _accu; var s = _s; if (s) { - _accu = Caml_curry.app2(f, s[2], fold(f, s[1], accu)); - _s = s[3]; + _accu = Caml_curry.app2(f, s[1], fold(f, s[0], accu)); + _s = s[2]; continue ; } @@ -574,9 +572,9 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[2])) { - if (for_all(p, param[1])) { - _param = param[3]; + if (Caml_curry.app1(p, param[1])) { + if (for_all(p, param[0])) { + _param = param[2]; continue ; } @@ -597,14 +595,14 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - if (Caml_curry.app1(p, param[2])) { + if (Caml_curry.app1(p, param[1])) { return /* true */1; } - else if (exists(p, param[1])) { + else if (exists(p, param[0])) { return /* true */1; } else { - _param = param[3]; + _param = param[2]; continue ; } @@ -616,10 +614,10 @@ function Make(Ord) { }; var filter = function (p, param) { if (param) { - var v = param[2]; - var l$prime = filter(p, param[1]); + var v = param[1]; + var l$prime = filter(p, param[0]); var pv = Caml_curry.app1(p, v); - var r$prime = filter(p, param[3]); + var r$prime = filter(p, param[2]); if (pv) { return join(l$prime, v, r$prime); } @@ -633,32 +631,29 @@ function Make(Ord) { }; var partition = function (p, param) { if (param) { - var v = param[2]; - var match = partition(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pv = Caml_curry.app1(p, v); - var match$1 = partition(p, param[3]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition(p, param[2]); + var rf = match$1[1]; + var rt = match$1[0]; if (pv) { - return [ - /* tuple */0, + return /* tuple */[ join(lt, v, rt), concat(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat(lt, rt), join(lf, v, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -666,7 +661,7 @@ function Make(Ord) { }; var cardinal = function (param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[3]); + return cardinal(param[0]) + 1 + cardinal(param[2]); } else { return 0; @@ -677,11 +672,10 @@ function Make(Ord) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - param[2], - elements_aux(accu, param[3]) + _param = param[0]; + _accu = /* :: */[ + param[1], + elements_aux(accu, param[2]) ]; continue ; @@ -698,10 +692,10 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - var v = param[2]; - var c = Caml_curry.app2(Ord[1], x, v); + var v = param[1]; + var c = Caml_curry.app2(Ord[0], x, v); if (c) { - _param = c < 0 ? param[1] : param[3]; + _param = c < 0 ? param[0] : param[2]; continue ; } @@ -723,23 +717,22 @@ function Make(Ord) { else { switch (n) { case 0 : - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, l ]; case 1 : if (l) { - return [ - /* tuple */0, - [ - /* Node */0, - /* Empty */0, - l[1], - /* Empty */0, - 1 - ], - l[2] + return /* tuple */[ + /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + l[1] ]; } else { @@ -748,24 +741,25 @@ function Make(Ord) { break; case 2 : if (l) { - var match = l[2]; + var match = l[1]; if (match) { - return [ - /* tuple */0, - [ - /* Node */0, - [ - /* Node */0, - /* Empty */0, - l[1], - /* Empty */0, - 1 - ], - match[1], - /* Empty */0, - 2 - ], - match[2] + return /* tuple */[ + /* Node */{ + 0: /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 1: match[0], + 2: /* Empty */0, + 3: 2, + length: 4, + tag: 0 + }, + match[1] ]; } else { @@ -778,32 +772,34 @@ function Make(Ord) { break; case 3 : if (l) { - var match$1 = l[2]; + var match$1 = l[1]; if (match$1) { - var match$2 = match$1[2]; + var match$2 = match$1[1]; if (match$2) { - return [ - /* tuple */0, - [ - /* Node */0, - [ - /* Node */0, - /* Empty */0, - l[1], - /* Empty */0, - 1 - ], - match$1[1], - [ - /* Node */0, - /* Empty */0, - match$2[1], - /* Empty */0, - 1 - ], - 2 - ], - match$2[2] + return /* tuple */[ + /* Node */{ + 0: /* Node */{ + 0: /* Empty */0, + 1: l[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 1: match$1[0], + 2: /* Node */{ + 0: /* Empty */0, + 1: match$2[0], + 2: /* Empty */0, + 3: 1, + length: 4, + tag: 0 + }, + 3: 2, + length: 4, + tag: 0 + }, + match$2[1] ]; } else { @@ -824,21 +820,18 @@ function Make(Ord) { if (exit === 1) { var nl = n / 2 | 0; var match$3 = sub(nl, l); - var l$1 = match$3[2]; + var l$1 = match$3[1]; if (l$1) { - var match$4 = sub(n - nl - 1, l$1[2]); - return [ - /* tuple */0, - create(match$3[1], l$1[1], match$4[1]), - match$4[2] + var match$4 = sub(n - nl - 1, l$1[1]); + return /* tuple */[ + create(match$3[0], l$1[0], match$4[0]), + match$4[1] ]; } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_set.ml", 372, 18 @@ -848,27 +841,27 @@ function Make(Ord) { } }; - return sub(List.length(l), l)[1]; + return sub(List.length(l), l)[0]; }; var of_list = function (l) { if (l) { - var match = l[2]; - var x0 = l[1]; + var match = l[1]; + var x0 = l[0]; if (match) { - var match$1 = match[2]; - var x1 = match[1]; + var match$1 = match[1]; + var x1 = match[0]; if (match$1) { - var match$2 = match$1[2]; - var x2 = match$1[1]; + var match$2 = match$1[1]; + var x2 = match$1[0]; if (match$2) { - var match$3 = match$2[2]; - var x3 = match$2[1]; + var match$3 = match$2[1]; + var x3 = match$2[0]; if (match$3) { - if (match$3[2]) { - return of_sorted_list(List.sort_uniq(Ord[1], l)); + if (match$3[1]) { + return of_sorted_list(List.sort_uniq(Ord[0], l)); } else { - return add(match$3[1], add(x3, add(x2, add(x1, singleton(x0))))); + return add(match$3[0], add(x3, add(x2, add(x1, singleton(x0))))); } } else { @@ -892,7 +885,6 @@ function Make(Ord) { } }; return [ - 0, height, create, bal, @@ -935,10 +927,7 @@ function Make(Ord) { ]; } -var N = [ - 0, - 3 -]; +var N = [3]; exports.Make = Make; exports.N = N; diff --git a/jscomp/test/test_simple_include.js b/jscomp/test/test_simple_include.js index d8a1541cda..605ce90fa7 100644 --- a/jscomp/test/test_simple_include.js +++ b/jscomp/test/test_simple_include.js @@ -5,26 +5,18 @@ var $$Array = require("../stdlib/array"); var a = 3; -var v = [ - 0, - 32 -]; +var v = [32]; -v[1] = 0; +v[0] = 0; var N = [ - 0, a, v ]; -var v$1 = [ - 0, - 32 -]; +var v$1 = [32]; var NN = [ - 0, 3, v$1 ]; diff --git a/jscomp/test/test_simple_obj.js b/jscomp/test/test_simple_obj.js index 1b99fb5a43..9fd924b5e9 100644 --- a/jscomp/test/test_simple_obj.js +++ b/jscomp/test/test_simple_obj.js @@ -6,13 +6,9 @@ var Caml_oo = require("../runtime/caml_oo"); var CamlinternalOO = require("../stdlib/camlinternalOO"); var Caml_curry = require("../runtime/caml_curry"); -var shared = [ - 0, - "add" -]; +var shared = ["add"]; var $$class = CamlinternalOO.create_table([ - 0, "hi", "id1", "id2", @@ -20,20 +16,19 @@ var $$class = CamlinternalOO.create_table([ ]); var ids = CamlinternalOO.get_method_labels($$class, [ - 0, "id2", "id1", "hi", "hello" ]); -var id2 = ids[1]; +var id2 = ids[0]; -var id1 = ids[2]; +var id1 = ids[1]; -var hi = ids[3]; +var hi = ids[2]; -var hello = ids[4]; +var hello = ids[3]; CamlinternalOO.set_methods($$class, /* array */[ hi, @@ -58,10 +53,7 @@ CamlinternalOO.init_class($$class); var u = CamlinternalOO.create_object_opt(0, $$class); -var $$class$1 = CamlinternalOO.create_table([ - 0, - "id" - ]); +var $$class$1 = CamlinternalOO.create_table(["id"]); var id = CamlinternalOO.get_method_label($$class$1, "id"); @@ -100,10 +92,8 @@ var v = CamlinternalOO.create_object_opt(0, $$class$3); function test() { if (Caml_curry.app1(Caml_oo.caml_get_public_method(uu, 23515, 1), uu) !== "uu") { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_simple_obj.ml", 21, 4 @@ -112,10 +102,8 @@ function test() { } if (Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 2), uuu, 1, 20) !== 21) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_simple_obj.ml", 22, 4 @@ -124,10 +112,8 @@ function test() { } if (Caml_curry.app3(Caml_oo.caml_get_public_method(v, 4846113, 3), v, 3, 7) !== 10) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_simple_obj.ml", 23, 4 @@ -136,10 +122,8 @@ function test() { } if (Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243894, 4), u) !== 3) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_simple_obj.ml", 25, 4 @@ -148,10 +132,8 @@ function test() { } if (Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243895, 5), u) !== 4) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_simple_obj.ml", 26, 4 @@ -160,10 +142,8 @@ function test() { } if (Caml_curry.app3(Caml_oo.caml_get_public_method(u, 23297, 6), u, 1, 2) !== 3) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_simple_obj.ml", 27, 4 @@ -175,10 +155,8 @@ function test() { } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_simple_obj.ml", 28, 4 diff --git a/jscomp/test/test_simple_pattern_match.js b/jscomp/test/test_simple_pattern_match.js index 2975e2f5bc..889bd74745 100644 --- a/jscomp/test/test_simple_pattern_match.js +++ b/jscomp/test/test_simple_pattern_match.js @@ -2,9 +2,14 @@ 'use strict'; -var a = 1; +var match = /* tuple */[ + 1, + 2 +]; -var b = 2; +var a = match[0]; + +var b = match[1]; exports.a = a; exports.b = b; diff --git a/jscomp/test/test_simple_ref.js b/jscomp/test/test_simple_ref.js index e53cadcbd4..b1cf383aaa 100644 --- a/jscomp/test/test_simple_ref.js +++ b/jscomp/test/test_simple_ref.js @@ -3,27 +3,18 @@ var Caml_curry = require("../runtime/caml_curry"); -var v = [ - 0, - 0 -]; +var v = [0]; function gen() { - ++ v[1]; - return v[1]; + ++ v[0]; + return v[0]; } -var h = [ - 0, - 0 -]; +var h = [0]; var a = 0; -var c = [ - 0, - 0 -]; +var c = [0]; var not_real_escape = a; diff --git a/jscomp/test/test_simple_tailcall.js b/jscomp/test/test_simple_tailcall.js index 2f03e8d890..9fbce42541 100644 --- a/jscomp/test/test_simple_tailcall.js +++ b/jscomp/test/test_simple_tailcall.js @@ -11,7 +11,7 @@ function tailcall() { function non_length(x) { if (x) { - return 1 + non_length(x[2]); + return 1 + non_length(x[1]); } else { return 0; @@ -23,9 +23,9 @@ function length(_acc, _x) { var x = _x; var acc = _acc; if (x) { - var tl = x[2]; + var tl = x[1]; if (tl) { - return 1 + length(acc + 1, tl[2]); + return 1 + length(acc + 1, tl[1]); } else { _x = tl; diff --git a/jscomp/test/test_sprintf.js b/jscomp/test/test_sprintf.js index f565f5589a..19616d145f 100644 --- a/jscomp/test/test_sprintf.js +++ b/jscomp/test/test_sprintf.js @@ -4,20 +4,23 @@ var Printf = require("../stdlib/printf"); var Caml_curry = require("../runtime/caml_curry"); -console.error(Caml_curry.app2(Printf.sprintf([ - /* Format */0, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "%d%s" - ]), 32, "ss")); +console.error(Caml_curry.app2(Printf.sprintf(/* Format */{ + 0: /* Int */{ + 0: /* Int_d */0, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* String */{ + 0: /* No_padding */0, + 1: /* End_of_format */0, + length: 2, + tag: 2 + }, + length: 4, + tag: 4 + }, + 1: "%d%s", + length: 2, + tag: 0 + }), 32, "ss")); /* Not a pure module */ diff --git a/jscomp/test/test_stack.js b/jscomp/test/test_stack.js index 8bdfd3bb96..88ee727971 100644 --- a/jscomp/test/test_stack.js +++ b/jscomp/test/test_stack.js @@ -3,7 +3,7 @@ function v(x) { - return +(x[1] === /* [] */0); + return +(x[0] === /* [] */0); } exports.v = v; diff --git a/jscomp/test/test_static_catch_ident.js b/jscomp/test/test_static_catch_ident.js index 8a5e742cb3..0b11145ffe 100644 --- a/jscomp/test/test_static_catch_ident.js +++ b/jscomp/test/test_static_catch_ident.js @@ -3,21 +3,22 @@ var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); -var Scan_failure = [ - 248, - "Test_static_catch_ident.Scan_failure", - ++ Caml_builtin_exceptions.caml_oo_last_id -]; +var Scan_failure = { + 0: "Test_static_catch_ident.Scan_failure", + 1: ++ Caml_builtin_exceptions.caml_oo_last_id, + length: 2, + tag: 248 +}; function scanf_bad_input(_, x) { var exit = 0; var s; - if (x[1] === Scan_failure) { - s = x[2]; + if (x[0] === Scan_failure) { + s = x[1]; exit = 1; } - else if (x[1] === Caml_builtin_exceptions.Failure) { - s = x[2]; + else if (x[0] === Caml_builtin_exceptions.Failure) { + s = x[1]; exit = 1; } else { diff --git a/jscomp/test/test_string.js b/jscomp/test/test_string.js index 25d34009f2..616bce1eae 100644 --- a/jscomp/test/test_string.js +++ b/jscomp/test/test_string.js @@ -11,10 +11,8 @@ function f(param) { return 1; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_string.ml", 4, 18 diff --git a/jscomp/test/test_string_case.js b/jscomp/test/test_string_case.js index e84a58db74..53068f8510 100644 --- a/jscomp/test/test_string_case.js +++ b/jscomp/test/test_string_case.js @@ -11,10 +11,8 @@ function f(param) { return 1; default: throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_string_case.ml", 4, 9 diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index e422e0cbe7..8190cf8bbc 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -7,7 +7,7 @@ var Caml_string = require("../runtime/caml_string"); function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -17,34 +17,34 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -52,7 +52,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -60,19 +59,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -80,30 +78,30 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; var c = Caml_string.caml_string_compare(x, v); if (c) { if (c < 0) { @@ -114,25 +112,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -140,14 +140,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_string.caml_string_compare(x, param[2]); + var c = Caml_string.caml_string_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -163,20 +163,17 @@ function timing(label, f) { } function assertion_test() { - var m = [ - 0, - /* Empty */0 - ]; + var m = [/* Empty */0]; var count = 1000000; timing("building", function () { for(var i = 0; i<= count; ++i){ - m[1] = add("" + i, "" + i, m[1]); + m[0] = add("" + i, "" + i, m[0]); } return /* () */0; }); return timing("querying", function () { for(var i = 0; i<= count; ++i){ - find("" + i, m[1]); + find("" + i, m[0]); } return /* () */0; }); diff --git a/jscomp/test/test_switch.js b/jscomp/test/test_switch.js index 7d652575e5..c1c00008de 100644 --- a/jscomp/test/test_switch.js +++ b/jscomp/test/test_switch.js @@ -13,7 +13,7 @@ function f(param) { } } else { - switch (param[0]) { + switch (param.tag | 0) { case 0 : return 0; case 1 : @@ -28,14 +28,15 @@ function f(param) { } function bind(x, f) { - if (x[0]) { + if (x.tag) { return x; } else { - return [ - /* Left */0, - Caml_curry.app1(f, x[1]) - ]; + return /* Left */{ + 0: Caml_curry.app1(f, x[0]), + length: 1, + tag: 0 + }; } } diff --git a/jscomp/test/test_trywith.js b/jscomp/test/test_trywith.js index 38273447e1..0edc3c05e6 100644 --- a/jscomp/test/test_trywith.js +++ b/jscomp/test/test_trywith.js @@ -12,15 +12,13 @@ function f(x) { return 2; } else { - switch (x[0]) { + switch (x.tag | 0) { case 0 : return 1; case 1 : throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_trywith.ml", 24, 9 diff --git a/jscomp/test/test_tuple.js b/jscomp/test/test_tuple.js index 4cef35ff59..ca0c9f0f7f 100644 --- a/jscomp/test/test_tuple.js +++ b/jscomp/test/test_tuple.js @@ -6,16 +6,14 @@ var r = 0; for(var k = 1; k<= 10; ++k){ for(var i = 1; i<= 10; ++i){ - var match = i % 2 ? [ - /* tuple */0, + var match = i % 2 ? /* tuple */[ 2, i * 3 - ] : [ - /* tuple */0, + ] : /* tuple */[ 1, i * 2 ]; - r = r * match[1] + match[2]; + r = r * match[0] + match[1]; } } diff --git a/jscomp/test/test_tuple_destructring.js b/jscomp/test/test_tuple_destructring.js index e233158f88..c8efa02961 100644 --- a/jscomp/test/test_tuple_destructring.js +++ b/jscomp/test/test_tuple_destructring.js @@ -4,10 +4,7 @@ var b = 3; -var N = [ - 0, - b -]; +var N = [b]; var h = 4; diff --git a/jscomp/test/test_type_based_arity.js b/jscomp/test/test_type_based_arity.js index 68b4df1ca4..65c24a46b7 100644 --- a/jscomp/test/test_type_based_arity.js +++ b/jscomp/test/test_type_based_arity.js @@ -11,7 +11,7 @@ function f1(g, x) { return Caml_curry.app1(g, x); } -var X = [0]; +var X = []; function f2(g, x) { return Caml_curry.app1(g, x); @@ -37,7 +37,7 @@ function f7(g, x) { return Caml_curry.app1(g, x); } -var X0 = [0]; +var X0 = []; function f8(g, x) { return Caml_curry.app1(g, x); @@ -63,10 +63,7 @@ function f13(g, x) { return Caml_curry.app1(g, x); } -var X2 = [ - 0, - f13 -]; +var X2 = [f13]; function f14(h, g, x) { return Caml_curry.app2(h, g, x); diff --git a/jscomp/test/test_while_closure.js b/jscomp/test/test_while_closure.js index 95d162ce15..a9bb9886e7 100644 --- a/jscomp/test/test_while_closure.js +++ b/jscomp/test/test_while_closure.js @@ -6,10 +6,7 @@ var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); var Caml_curry = require("../runtime/caml_curry"); -var v = [ - 0, - 0 -]; +var v = [0]; var count = 10; @@ -23,7 +20,7 @@ function f() { var j = n; arr[j] = (function(j){ return function () { - v[1] += j; + v[0] += j; return /* () */0; } }(j)); @@ -38,16 +35,14 @@ $$Array.iter(function (x) { return Caml_curry.app1(x, /* () */0); }, arr); -var n = v[1]; +var n = v[0]; console.log("" + n); -if (v[1] !== 45) { +if (v[0] !== 45) { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "test_while_closure.ml", 63, 4 diff --git a/jscomp/test/test_while_side_effect.js b/jscomp/test/test_while_side_effect.js index 391902f9e4..3ae91d3e90 100644 --- a/jscomp/test/test_while_side_effect.js +++ b/jscomp/test/test_while_side_effect.js @@ -2,16 +2,13 @@ 'use strict'; -var v = [ - 0, - 0 -]; +var v = [0]; while(function () { - var n = v[1]; + var n = v[0]; console.log("" + n); - ++ v[1]; - return +(v[1] < 10); + ++ v[0]; + return +(v[0] < 10); }()) { }; @@ -25,18 +22,15 @@ function fib(n) { } } -var x = [ - 0, - 3 -]; +var x = [3]; while(function () { var y = 3; - var n = x[1]; + var n = x[0]; console.log("" + n); ++ y; - ++ x[1]; - return +(fib(x[1]) + fib(x[1]) < 20); + ++ x[0]; + return +(fib(x[0]) + fib(x[0]) < 20); }()) { console.log("" + 3); }; diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 09ad40d96c..b218ed091a 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -2,10 +2,10 @@ 'use strict'; var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions"); +var Caml_obj = require("../runtime/caml_obj"); var Pervasives = require("../stdlib/pervasives"); var Caml_format = require("../runtime/caml_format"); var Printf = require("../stdlib/printf"); -var Caml_primitive = require("../runtime/caml_primitive"); var $$String = require("../stdlib/string"); var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); @@ -27,8 +27,7 @@ function split(delim, s) { } catch (exn){ if (exn === Caml_builtin_exceptions.Not_found) { - return [ - /* :: */0, + return /* :: */[ $$String.sub(s, 0, i), l ]; @@ -38,14 +37,12 @@ function split(delim, s) { } } if (exit === 1) { - var l_001 = $$String.sub(s, i$prime + 1, i - i$prime - 1); - var l$1 = [ - /* :: */0, - l_001, + var l_000 = $$String.sub(s, i$prime + 1, i - i$prime - 1); + var l$1 = /* :: */[ + l_000, l ]; - var l$2 = i$prime ? l$1 : [ - /* :: */0, + var l$2 = i$prime ? l$1 : /* :: */[ "", l$1 ]; @@ -68,7 +65,7 @@ function split(delim, s) { function string_of_float_option(param) { if (param) { - return Pervasives.string_of_float(param[1]); + return Pervasives.string_of_float(param[0]); } else { return "nan"; @@ -76,7 +73,6 @@ function string_of_float_option(param) { } var Util = [ - 0, split, string_of_float_option ]; @@ -91,39 +87,43 @@ function string_of_rank(param) { } } else { - return Caml_curry.app1(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "Ranked(", - [ - /* Int */4, - /* Int_i */3, - /* No_padding */0, - /* No_precision */0, - [ - /* Char_literal */12, - /* ")" */41, - /* End_of_format */0 - ] - ] - ], - "Ranked(%i)" - ]), param[1]); + return Caml_curry.app1(Printf.sprintf(/* Format */{ + 0: /* String_literal */{ + 0: "Ranked(", + 1: /* Int */{ + 0: /* Int_i */3, + 1: /* No_padding */0, + 2: /* No_precision */0, + 3: /* Char_literal */{ + 0: /* ")" */41, + 1: /* End_of_format */0, + length: 2, + tag: 12 + }, + length: 4, + tag: 4 + }, + length: 2, + tag: 11 + }, + 1: "Ranked(%i)", + length: 2, + tag: 0 + }), param[0]); } } function find_ticker_by_name(all_tickers, ticker) { return List.find(function (param) { - return +(param[3] === ticker); + return +(param[2] === ticker); }, all_tickers); } function print_all_composite(all_tickers) { return List.iter(function (param) { - var value = param[1]; - var ticker_name = param[3]; - if (param[4]) { + var value = param[0]; + var ticker_name = param[2]; + if (param[3]) { if (value) { console.log(ticker_name); return /* () */0; @@ -141,7 +141,7 @@ function print_all_composite(all_tickers) { function height(param) { if (param) { - return param[5]; + return param[4]; } else { return 0; @@ -151,45 +151,46 @@ function height(param) { function create(l, x, d, r) { var hl = height(l); var hr = height(r); - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } function singleton(x, d) { - return [ - /* Node */0, - /* Empty */0, - x, - d, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: d, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } function bal(l, x, d, r) { - var hl = l ? l[5] : 0; - var hr = r ? r[5] : 0; + var hl = l ? l[4] : 0; + var hr = r ? r[4] : 0; if (hl > hr + 2) { if (l) { - var lr = l[4]; - var ld = l[3]; - var lv = l[2]; - var ll = l[1]; + var lr = l[3]; + var ld = l[2]; + var lv = l[1]; + var ll = l[0]; if (height(ll) >= height(lr)) { return create(ll, lv, ld, create(lr, x, d, r)); } else if (lr) { - return create(create(ll, lv, ld, lr[1]), lr[2], lr[3], create(lr[4], x, d, r)); + return create(create(ll, lv, ld, lr[0]), lr[1], lr[2], create(lr[3], x, d, r)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -197,7 +198,6 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -205,19 +205,18 @@ function bal(l, x, d, r) { } else if (hr > hl + 2) { if (r) { - var rr = r[4]; - var rd = r[3]; - var rv = r[2]; - var rl = r[1]; + var rr = r[3]; + var rd = r[2]; + var rv = r[1]; + var rl = r[0]; if (height(rr) >= height(rl)) { return create(create(l, x, d, rl), rv, rd, rr); } else if (rl) { - return create(create(l, x, d, rl[1]), rl[2], rl[3], create(rl[4], rv, rd, rr)); + return create(create(l, x, d, rl[0]), rl[1], rl[2], create(rl[3], rv, rd, rr)); } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; @@ -225,21 +224,21 @@ function bal(l, x, d, r) { } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.bal" ]; } } else { - return [ - /* Node */0, - l, - x, - d, - r, - hl >= hr ? hl + 1 : hr + 1 - ]; + return /* Node */{ + 0: l, + 1: x, + 2: d, + 3: r, + 4: hl >= hr ? hl + 1 : hr + 1, + length: 5, + tag: 0 + }; } } @@ -254,11 +253,11 @@ function is_empty(param) { function add(x, data, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_compare(x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -268,25 +267,27 @@ function add(x, data, param) { } } else { - return [ - /* Node */0, - l, - x, - data, - r, - param[5] - ]; + return /* Node */{ + 0: l, + 1: x, + 2: data, + 3: r, + 4: param[4], + length: 5, + tag: 0 + }; } } else { - return [ - /* Node */0, - /* Empty */0, - x, - data, - /* Empty */0, - 1 - ]; + return /* Node */{ + 0: /* Empty */0, + 1: x, + 2: data, + 3: /* Empty */0, + 4: 1, + length: 5, + tag: 0 + }; } } @@ -294,14 +295,14 @@ function find(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_compare(x, param[2]); + var c = Caml_obj.caml_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } else { - return param[3]; + return param[2]; } } else { @@ -314,9 +315,9 @@ function mem(x, _param) { while(true) { var param = _param; if (param) { - var c = Caml_primitive.caml_compare(x, param[2]); + var c = Caml_obj.caml_compare(x, param[1]); if (c) { - _param = c < 0 ? param[1] : param[4]; + _param = c < 0 ? param[0] : param[3]; continue ; } @@ -334,17 +335,16 @@ function min_binding(_param) { while(true) { var param = _param; if (param) { - var l = param[1]; + var l = param[0]; if (l) { _param = l; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -358,17 +358,16 @@ function max_binding(_param) { while(true) { var param = _param; if (param) { - var r = param[4]; + var r = param[3]; if (r) { _param = r; continue ; } else { - return [ - /* tuple */0, - param[2], - param[3] + return /* tuple */[ + param[1], + param[2] ]; } } @@ -380,17 +379,16 @@ function max_binding(_param) { function remove_min_binding(param) { if (param) { - var l = param[1]; + var l = param[0]; if (l) { - return bal(remove_min_binding(l), param[2], param[3], param[4]); + return bal(remove_min_binding(l), param[1], param[2], param[3]); } else { - return param[4]; + return param[3]; } } else { throw [ - 0, Caml_builtin_exceptions.Invalid_argument, "Map.remove_min_elt" ]; @@ -399,11 +397,11 @@ function remove_min_binding(param) { function remove(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_compare(x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, d, r); @@ -418,7 +416,7 @@ function remove(x, param) { if (t1) { if (t2) { var match = min_binding(t2); - return bal(t1, match[1], match[2], remove_min_binding(t2)); + return bal(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -438,9 +436,9 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - iter(f, param[1]); - Caml_curry.app2(f, param[2], param[3]); - _param = param[4]; + iter(f, param[0]); + Caml_curry.app2(f, param[1], param[2]); + _param = param[3]; continue ; } @@ -452,17 +450,18 @@ function iter(f, _param) { function map(f, param) { if (param) { - var l$prime = map(f, param[1]); - var d$prime = Caml_curry.app1(f, param[3]); - var r$prime = map(f, param[4]); - return [ - /* Node */0, - l$prime, - param[2], - d$prime, - r$prime, - param[5] - ]; + var l$prime = map(f, param[0]); + var d$prime = Caml_curry.app1(f, param[2]); + var r$prime = map(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: param[1], + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -471,18 +470,19 @@ function map(f, param) { function mapi(f, param) { if (param) { - var v = param[2]; - var l$prime = mapi(f, param[1]); - var d$prime = Caml_curry.app2(f, v, param[3]); - var r$prime = mapi(f, param[4]); - return [ - /* Node */0, - l$prime, - v, - d$prime, - r$prime, - param[5] - ]; + var v = param[1]; + var l$prime = mapi(f, param[0]); + var d$prime = Caml_curry.app2(f, v, param[2]); + var r$prime = mapi(f, param[3]); + return /* Node */{ + 0: l$prime, + 1: v, + 2: d$prime, + 3: r$prime, + 4: param[4], + length: 5, + tag: 0 + }; } else { return /* Empty */0; @@ -494,8 +494,8 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); - _m = m[4]; + _accu = Caml_curry.app3(f, m[1], m[2], fold(f, m[0], accu)); + _m = m[3]; continue ; } @@ -509,9 +509,9 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { - if (for_all(p, param[1])) { - _param = param[4]; + if (Caml_curry.app2(p, param[1], param[2])) { + if (for_all(p, param[0])) { + _param = param[3]; continue ; } @@ -533,14 +533,14 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (Caml_curry.app2(p, param[2], param[3])) { + if (Caml_curry.app2(p, param[1], param[2])) { return /* true */1; } - else if (exists(p, param[1])) { + else if (exists(p, param[0])) { return /* true */1; } else { - _param = param[4]; + _param = param[3]; continue ; } @@ -553,7 +553,7 @@ function exists(p, _param) { function add_min_binding(k, v, param) { if (param) { - return bal(add_min_binding(k, v, param[1]), param[2], param[3], param[4]); + return bal(add_min_binding(k, v, param[0]), param[1], param[2], param[3]); } else { return singleton(k, v); @@ -562,7 +562,7 @@ function add_min_binding(k, v, param) { function add_max_binding(k, v, param) { if (param) { - return bal(param[1], param[2], param[3], add_max_binding(k, v, param[4])); + return bal(param[0], param[1], param[2], add_max_binding(k, v, param[3])); } else { return singleton(k, v); @@ -572,13 +572,13 @@ function add_max_binding(k, v, param) { function join(l, v, d, r) { if (l) { if (r) { - var rh = r[5]; - var lh = l[5]; + var rh = r[4]; + var lh = l[4]; if (lh > rh + 2) { - return bal(l[1], l[2], l[3], join(l[4], v, d, r)); + return bal(l[0], l[1], l[2], join(l[3], v, d, r)); } else if (rh > lh + 2) { - return bal(join(l, v, d, r[1]), r[2], r[3], r[4]); + return bal(join(l, v, d, r[0]), r[1], r[2], r[3]); } else { return create(l, v, d, r); @@ -597,7 +597,7 @@ function concat(t1, t2) { if (t1) { if (t2) { var match = min_binding(t2); - return join(t1, match[1], match[2], remove_min_binding(t2)); + return join(t1, match[0], match[1], remove_min_binding(t2)); } else { return t1; @@ -610,7 +610,7 @@ function concat(t1, t2) { function concat_or_join(t1, v, d, t2) { if (d) { - return join(t1, v, d[1], t2); + return join(t1, v, d[0], t2); } else { return concat(t1, t2); @@ -619,46 +619,39 @@ function concat_or_join(t1, v, d, t2) { function split$1(x, param) { if (param) { - var r = param[4]; - var d = param[3]; - var v = param[2]; - var l = param[1]; - var c = Caml_primitive.caml_compare(x, v); + var r = param[3]; + var d = param[2]; + var v = param[1]; + var l = param[0]; + var c = Caml_obj.caml_compare(x, v); if (c) { if (c < 0) { var match = split$1(x, l); - return [ - /* tuple */0, + return /* tuple */[ + match[0], match[1], - match[2], - join(match[3], v, d, r) + join(match[2], v, d, r) ]; } else { var match$1 = split$1(x, r); - return [ - /* tuple */0, - join(l, v, d, match$1[1]), - match$1[2], - match$1[3] + return /* tuple */[ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ l, - [ - /* Some */0, - d - ], + /* Some */[d], r ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* None */0, /* Empty */0 @@ -669,13 +662,10 @@ function split$1(x, param) { function merge(f, s1, s2) { var exit = 0; if (s1) { - var v1 = s1[2]; - if (s1[5] >= height(s2)) { + var v1 = s1[1]; + if (s1[4] >= height(s2)) { var match = split$1(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, Caml_curry.app3(f, v1, [ - /* Some */0, - s1[3] - ], match[2]), merge(f, s1[4], match[3])); + return concat_or_join(merge(f, s1[0], match[0]), v1, Caml_curry.app3(f, v1, /* Some */[s1[2]], match[1]), merge(f, s1[3], match[2])); } else { exit = 1; @@ -689,19 +679,14 @@ function merge(f, s1, s2) { } if (exit === 1) { if (s2) { - var v2 = s2[2]; + var v2 = s2[1]; var match$1 = split$1(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, Caml_curry.app3(f, v2, match$1[2], [ - /* Some */0, - s2[3] - ]), merge(f, match$1[3], s2[4])); + return concat_or_join(merge(f, match$1[0], s2[0]), v2, Caml_curry.app3(f, v2, match$1[1], /* Some */[s2[2]]), merge(f, match$1[2], s2[3])); } else { throw [ - 0, Caml_builtin_exceptions.Assert_failure, [ - 0, "map.ml", 270, 10 @@ -714,11 +699,11 @@ function merge(f, s1, s2) { function filter(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var l$prime = filter(p, param[1]); + var d = param[2]; + var v = param[1]; + var l$prime = filter(p, param[0]); var pvd = Caml_curry.app2(p, v, d); - var r$prime = filter(p, param[4]); + var r$prime = filter(p, param[3]); if (pvd) { return join(l$prime, v, d, r$prime); } @@ -733,33 +718,30 @@ function filter(p, param) { function partition(p, param) { if (param) { - var d = param[3]; - var v = param[2]; - var match = partition(p, param[1]); - var lf = match[2]; - var lt = match[1]; + var d = param[2]; + var v = param[1]; + var match = partition(p, param[0]); + var lf = match[1]; + var lt = match[0]; var pvd = Caml_curry.app2(p, v, d); - var match$1 = partition(p, param[4]); - var rf = match$1[2]; - var rt = match$1[1]; + var match$1 = partition(p, param[3]); + var rf = match$1[1]; + var rt = match$1[0]; if (pvd) { - return [ - /* tuple */0, + return /* tuple */[ join(lt, v, d, rt), concat(lf, rf) ]; } else { - return [ - /* tuple */0, + return /* tuple */[ concat(lt, rt), join(lf, v, d, rf) ]; } } else { - return [ - /* tuple */0, + return /* tuple */[ /* Empty */0, /* Empty */0 ]; @@ -771,14 +753,15 @@ function cons_enum(_m, _e) { var e = _e; var m = _m; if (m) { - _e = [ - /* More */0, - m[2], - m[3], - m[4], - e - ]; - _m = m[1]; + _e = /* More */{ + 0: m[1], + 1: m[2], + 2: m[3], + 3: e, + length: 4, + tag: 0 + }; + _m = m[0]; continue ; } @@ -796,18 +779,18 @@ function compare(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - var c = Caml_primitive.caml_compare(e1[1], e2[1]); + var c = Caml_obj.caml_compare(e1[0], e2[0]); if (c !== 0) { return c; } else { - var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[1], e2[1]); if (c$1 !== 0) { return c$1; } else { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -834,12 +817,12 @@ function equal(cmp, m1, m2) { var e1 = _e1; if (e1) { if (e2) { - if (Caml_primitive.caml_compare(e1[1], e2[1])) { + if (Caml_obj.caml_compare(e1[0], e2[0])) { return /* false */0; } - else if (Caml_curry.app2(cmp, e1[2], e2[2])) { - _e2 = cons_enum(e2[3], e2[4]); - _e1 = cons_enum(e1[3], e1[4]); + else if (Caml_curry.app2(cmp, e1[1], e2[1])) { + _e2 = cons_enum(e2[2], e2[3]); + _e1 = cons_enum(e1[2], e1[3]); continue ; } @@ -862,7 +845,7 @@ function equal(cmp, m1, m2) { function cardinal(param) { if (param) { - return cardinal(param[1]) + 1 + cardinal(param[4]); + return cardinal(param[0]) + 1 + cardinal(param[3]); } else { return 0; @@ -874,15 +857,13 @@ function bindings_aux(_accu, _param) { var param = _param; var accu = _accu; if (param) { - _param = param[1]; - _accu = [ - /* :: */0, - [ - /* tuple */0, - param[2], - param[3] + _param = param[0]; + _accu = /* :: */[ + /* tuple */[ + param[1], + param[2] ], - bindings_aux(accu, param[4]) + bindings_aux(accu, param[3]) ]; continue ; @@ -898,7 +879,6 @@ function bindings(s) { } var Ticker_map = [ - 0, /* Empty */0, is_empty, mem, @@ -928,31 +908,33 @@ var Ticker_map = [ function compute_update_sequences(all_tickers) { List.fold_left(function (counter, ticker) { var loop = function (counter, ticker) { - var rank = ticker[2]; + var rank = ticker[1]; if (typeof rank === "number") { if (rank !== 0) { return counter; } else { - ticker[2] = /* Visited */1; - var match = ticker[4]; + ticker[1] = /* Visited */1; + var match = ticker[3]; if (match) { - var match$1 = match[1]; - var counter$1 = loop(counter, match$1[3]); - var counter$2 = loop(counter$1, match$1[2]); + var match$1 = match[0]; + var counter$1 = loop(counter, match$1[2]); + var counter$2 = loop(counter$1, match$1[1]); var counter$3 = counter$2 + 1; - ticker[2] = [ - /* Ranked */0, - counter$3 - ]; + ticker[1] = /* Ranked */{ + 0: counter$3, + length: 1, + tag: 0 + }; return counter$3; } else { var counter$4 = counter + 1; - ticker[2] = [ - /* Ranked */0, - counter$4 - ]; + ticker[1] = /* Ranked */{ + 0: counter$4, + length: 1, + tag: 0 + }; return counter$4; } } @@ -964,25 +946,23 @@ function compute_update_sequences(all_tickers) { return loop(counter, ticker); }, 0, all_tickers); var map = List.fold_left(function (map, ticker) { - if (ticker[4]) { + if (ticker[3]) { var loop = function (_up, _map, _ticker) { while(true) { var ticker = _ticker; var map = _map; var up = _up; - var type_ = ticker[4]; - var ticker_name = ticker[3]; + var type_ = ticker[3]; + var ticker_name = ticker[2]; if (type_) { - var match = type_[1]; - var map$1 = loop([ - /* :: */0, + var match = type_[0]; + var map$1 = loop(/* :: */[ ticker, up - ], map, match[3]); - _ticker = match[2]; + ], map, match[2]); + _ticker = match[1]; _map = map$1; - _up = [ - /* :: */0, + _up = /* :: */[ ticker, up ]; @@ -998,8 +978,7 @@ function compute_update_sequences(all_tickers) { return loop(/* [] */0, map, ticker); } else { - return add(ticker[3], [ - /* :: */0, + return add(ticker[2], /* :: */[ ticker, /* [] */0 ], map); @@ -1007,24 +986,22 @@ function compute_update_sequences(all_tickers) { }, /* Empty */0, List.rev(all_tickers)); return fold(function (k, l, map) { var l$1 = List.sort_uniq(function (param, param$1) { - var lhs = param[2]; - var rhs = param$1[2]; + var lhs = param[1]; + var rhs = param$1[1]; if (typeof lhs === "number") { throw [ - 0, Caml_builtin_exceptions.Failure, "All nodes should be ranked" ]; } else if (typeof rhs === "number") { throw [ - 0, Caml_builtin_exceptions.Failure, "All nodes should be ranked" ]; } else { - return Caml_primitive.caml_int_compare(lhs[1], rhs[1]); + return Caml_obj.caml_int_compare(lhs[0], rhs[0]); } }, l); return add(k, l$1, map); @@ -1034,23 +1011,17 @@ function compute_update_sequences(all_tickers) { function process_quote(ticker_map, new_ticker, new_value) { var update_sequence = find(new_ticker, ticker_map); return List.iter(function (ticker) { - var match = ticker[4]; + var match = ticker[3]; if (match) { - var match$1 = match[1]; - var match$2 = match$1[3][1]; - var match$3 = match$1[2][1]; + var match$1 = match[0]; + var match$2 = match$1[2][0]; + var match$3 = match$1[1][0]; var value; if (match$2) { if (match$3) { - var y = match$3[1]; - var x = match$2[1]; - value = match$1[1] !== 0 ? [ - /* Some */0, - x - y - ] : [ - /* Some */0, - x + y - ]; + var y = match$3[0]; + var x = match$2[0]; + value = match$1[0] !== 0 ? /* Some */[x - y] : /* Some */[x + y]; } else { value = /* None */0; @@ -1059,19 +1030,15 @@ function process_quote(ticker_map, new_ticker, new_value) { else { value = /* None */0; } - ticker[1] = value; + ticker[0] = value; return /* () */0; } - else if (ticker[3] === new_ticker) { - ticker[1] = [ - /* Some */0, - new_value - ]; + else if (ticker[2] === new_ticker) { + ticker[0] = /* Some */[new_value]; return /* () */0; } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Only single Market ticker should be udpated upon a new quote" ]; @@ -1083,54 +1050,47 @@ function process_input_line(ticker_map, all_tickers, line) { var make_binary_op = function (ticker_name, lhs, rhs, op) { var lhs$1 = find_ticker_by_name(all_tickers, lhs); var rhs$1 = find_ticker_by_name(all_tickers, rhs); - return [ - /* record */0, + return /* record */[ /* None */0, /* Uninitialized */0, ticker_name, - [ - /* Binary_op */0, - [ - /* record */0, + /* Binary_op */{ + 0: /* record */[ op, rhs$1, lhs$1 - ] - ] + ], + length: 1, + tag: 0 + } ]; }; var tokens = split(/* "|" */124, line); if (tokens) { - switch (tokens[1]) { + switch (tokens[0]) { case "Q" : - var match = tokens[2]; + var match = tokens[1]; if (match) { - var match$1 = match[2]; + var match$1 = match[1]; if (match$1) { - if (match$1[2]) { + if (match$1[1]) { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; } else { - var ticker_map$1 = ticker_map ? ticker_map[1] : compute_update_sequences(all_tickers); - var value = Caml_format.caml_float_of_string(match$1[1]); - process_quote(ticker_map$1, match[1], value); - return [ - /* tuple */0, + var ticker_map$1 = ticker_map ? ticker_map[0] : compute_update_sequences(all_tickers); + var value = Caml_format.caml_float_of_string(match$1[0]); + process_quote(ticker_map$1, match[0], value); + return /* tuple */[ all_tickers, - [ - /* Some */0, - ticker_map$1 - ] + /* Some */[ticker_map$1] ]; } } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1138,37 +1098,33 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; } break; case "R" : - var match$2 = tokens[2]; + var match$2 = tokens[1]; if (match$2) { - var match$3 = match$2[2]; + var match$3 = match$2[1]; if (match$3) { - var ticker_name = match$2[1]; - switch (match$3[1]) { + var ticker_name = match$2[0]; + switch (match$3[0]) { case "+" : - var match$4 = match$3[2]; + var match$4 = match$3[1]; if (match$4) { - var match$5 = match$4[2]; + var match$5 = match$4[1]; if (match$5) { - if (match$5[2]) { + if (match$5[1]) { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; } else { - return [ - /* tuple */0, - [ - /* :: */0, - make_binary_op(ticker_name, match$4[1], match$5[1], /* PLUS */0), + return /* tuple */[ + /* :: */[ + make_binary_op(ticker_name, match$4[0], match$5[0], /* PLUS */0), all_tickers ], ticker_map @@ -1177,7 +1133,6 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1185,30 +1140,26 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; } break; case "-" : - var match$6 = match$3[2]; + var match$6 = match$3[1]; if (match$6) { - var match$7 = match$6[2]; + var match$7 = match$6[1]; if (match$7) { - if (match$7[2]) { + if (match$7[1]) { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; } else { - return [ - /* tuple */0, - [ - /* :: */0, - make_binary_op(ticker_name, match$6[1], match$7[1], /* MINUS */1), + return /* tuple */[ + /* :: */[ + make_binary_op(ticker_name, match$6[0], match$7[0], /* MINUS */1), all_tickers ], ticker_map @@ -1217,7 +1168,6 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1225,27 +1175,22 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; } break; case "S" : - if (match$3[2]) { + if (match$3[1]) { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; } else { - return [ - /* tuple */0, - [ - /* :: */0, - [ - /* record */0, + return /* tuple */[ + /* :: */[ + /* record */[ /* None */0, /* Uninitialized */0, ticker_name, @@ -1259,7 +1204,6 @@ function process_input_line(ticker_map, all_tickers, line) { break; default: throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1267,7 +1211,6 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1275,7 +1218,6 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1283,7 +1225,6 @@ function process_input_line(ticker_map, all_tickers, line) { break; default: throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1291,7 +1232,6 @@ function process_input_line(ticker_map, all_tickers, line) { } else { throw [ - 0, Caml_builtin_exceptions.Failure, "Invalid input line" ]; @@ -1302,10 +1242,10 @@ function loop(_lines, _param) { while(true) { var param = _param; var lines = _lines; - var all_tickers = param[1]; + var all_tickers = param[0]; if (lines) { - _param = process_input_line(param[2], all_tickers, lines[1]); - _lines = lines[2]; + _param = process_input_line(param[1], all_tickers, lines[0]); + _lines = lines[1]; continue ; } @@ -1315,32 +1255,23 @@ function loop(_lines, _param) { }; } -var lines = [ - /* :: */0, +var lines = /* :: */[ "R|MSFT|S", - [ - /* :: */0, + /* :: */[ "R|IBM|S", - [ - /* :: */0, + /* :: */[ "R|FB|S", - [ - /* :: */0, + /* :: */[ "R|CP1|+|MSFT|IBM", - [ - /* :: */0, + /* :: */[ "R|CP2|-|FB|IBM", - [ - /* :: */0, + /* :: */[ "R|CP12|+|CP1|CP2", - [ - /* :: */0, + /* :: */[ "Q|MSFT|120.", - [ - /* :: */0, + /* :: */[ "Q|IBM|130.", - [ - /* :: */0, + /* :: */[ "Q|FB|80.", /* [] */0 ] diff --git a/jscomp/test/typeof_test.js b/jscomp/test/typeof_test.js index a4fdf44934..d6619ea164 100644 --- a/jscomp/test/typeof_test.js +++ b/jscomp/test/typeof_test.js @@ -3,38 +3,36 @@ var Mt = require("./mt"); -var suites_001 = [ - /* tuple */0, +var suites_000 = /* tuple */[ "int_type", function () { - return [ - /* Eq */0, - "number", - "number" - ]; + return /* Eq */{ + 0: "number", + 1: "number", + length: 2, + tag: 0 + }; } ]; -var suites_002 = [ - /* :: */0, - [ - /* tuple */0, +var suites_001 = /* :: */[ + /* tuple */[ "string_type", function () { - return [ - /* Eq */0, - "string", - "string" - ]; + return /* Eq */{ + 0: "string", + 1: "string", + length: 2, + tag: 0 + }; } ], /* [] */0 ]; -var suites = [ - /* :: */0, - suites_001, - suites_002 +var suites = /* :: */[ + suites_000, + suites_001 ]; Mt.from_pair_suites("typeof_test.ml", suites);