From 37d8829f3bc6eb8ed5603534e88a6a4be6cc4fd4 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Sat, 6 Feb 2016 09:40:16 -0500 Subject: [PATCH 1/5] start support currying --- jscomp/js_config.ml | 24 + jscomp/js_config.mli | 25 + jscomp/js_dump.ml | 24 +- jscomp/js_fold_basic.ml | 11 +- jscomp/js_helper.ml | 24 - jscomp/js_helper.mli | 20 - jscomp/js_of_lam_string.ml | 8 +- jscomp/lam_compile.ml | 6 +- jscomp/lam_compile_global.ml | 2 +- jscomp/lam_compile_group.ml | 2 +- jscomp/lam_dispatch_primitive.ml | 32 +- jscomp/runtime/.depend | 8 +- jscomp/runtime/caml_curry.d.ts | 18 + jscomp/runtime/caml_curry.js | 207 ++++++ jscomp/runtime/{curry.ml => caml_curry.ml} | 0 jscomp/runtime/runtime.mllib | 2 +- jscomp/stdlib/arg.js | 347 +++++----- jscomp/stdlib/array.js | 35 +- jscomp/stdlib/buffer.js | 7 +- jscomp/stdlib/bytes.js | 13 +- jscomp/stdlib/camlinternalFormat.js | 727 +++++++++++---------- jscomp/stdlib/camlinternalLazy.js | 5 +- jscomp/stdlib/camlinternalMod.js | 3 +- jscomp/stdlib/camlinternalOO.js | 55 +- jscomp/stdlib/digest.js | 13 +- jscomp/stdlib/filename.js | 59 +- jscomp/stdlib/format.js | 57 +- jscomp/stdlib/gc.js | 503 +++++++------- jscomp/stdlib/hashtbl.js | 47 +- jscomp/stdlib/lexing.js | 3 +- jscomp/stdlib/list.js | 101 +-- jscomp/stdlib/map.js | 39 +- jscomp/stdlib/marshal.js | 3 +- jscomp/stdlib/parsing.js | 9 +- jscomp/stdlib/pervasives.js | 7 +- jscomp/stdlib/printexc.js | 329 +++++----- jscomp/stdlib/printf.js | 9 +- jscomp/stdlib/queue.js | 5 +- jscomp/stdlib/random.js | 3 +- jscomp/stdlib/scanf.js | 367 +++++------ jscomp/stdlib/set.js | 27 +- jscomp/stdlib/sort.js | 21 +- jscomp/stdlib/stream.js | 17 +- jscomp/stdlib/string.js | 45 +- jscomp/stdlib/weak.js | 29 +- jscomp/test/.depend | 4 + jscomp/test/a_recursive_type.js | 3 +- jscomp/test/ari_regress_test.js | 5 +- jscomp/test/arith_lexer.js | 3 +- jscomp/test/array_test.js | 3 +- jscomp/test/cps_test.js | 9 +- jscomp/test/demo.js | 43 +- jscomp/test/demo_page.js | 15 +- jscomp/test/ext_filename.js | 15 +- jscomp/test/ext_list.js | 35 +- jscomp/test/ext_string.js | 7 +- jscomp/test/for_loop_test.js | 21 +- jscomp/test/inline_regression_test.js | 11 +- jscomp/test/int_map.js | 25 +- jscomp/test/lexer_test.js | 3 +- jscomp/test/map_test.js | 5 +- jscomp/test/mt.js | 23 +- jscomp/test/number_lexer.js | 29 +- jscomp/test/obj_test.js | 35 +- jscomp/test/printf_test.d.ts | 2 + jscomp/test/printf_test.js | 43 ++ jscomp/test/printf_test.ml | 9 + jscomp/test/qcc.js | 423 ++++++------ jscomp/test/record_with_test.js | 5 +- jscomp/test/simple_lexer_test.js | 9 +- jscomp/test/small_inline_test.js | 13 +- jscomp/test/test.mllib | 3 +- jscomp/test/test_ari.js | 13 +- jscomp/test/test_array.js | 3 +- jscomp/test/test_bytes.js | 3 +- jscomp/test/test_closure.js | 3 +- jscomp/test/test_cps.js | 5 +- jscomp/test/test_demo.js | 5 +- jscomp/test/test_external.js | 5 +- jscomp/test/test_ffi.js | 3 +- jscomp/test/test_fib.js | 3 +- jscomp/test/test_for_loop.js | 11 +- jscomp/test/test_for_map.js | 25 +- jscomp/test/test_format.js | 25 +- jscomp/test/test_internalOO.js | 131 ++-- jscomp/test/test_js_ffi.js | 5 +- jscomp/test/test_list.js | 101 +-- jscomp/test/test_match_exception.js | 3 +- jscomp/test/test_nested_print.js | 3 +- jscomp/test/test_obj.js | 5 +- jscomp/test/test_per.js | 9 +- jscomp/test/test_primitive.js | 3 +- jscomp/test/test_react.js | 21 +- jscomp/test/test_scope.js | 5 +- jscomp/test/test_seq.js | 3 +- jscomp/test/test_set.js | 27 +- jscomp/test/test_simple_obj.js | 15 +- jscomp/test/test_simple_ref.js | 3 +- jscomp/test/test_sprintf.js | 29 +- jscomp/test/test_string_map.js | 7 +- jscomp/test/test_switch.js | 3 +- jscomp/test/test_type_based_arity.js | 31 +- jscomp/test/test_while_closure.js | 3 +- jscomp/test/ticker.js | 57 +- 104 files changed, 2530 insertions(+), 2137 deletions(-) create mode 100644 jscomp/runtime/caml_curry.d.ts create mode 100644 jscomp/runtime/caml_curry.js rename jscomp/runtime/{curry.ml => caml_curry.ml} (100%) create mode 100644 jscomp/test/printf_test.d.ts create mode 100644 jscomp/test/printf_test.js create mode 100644 jscomp/test/printf_test.ml diff --git a/jscomp/js_config.ml b/jscomp/js_config.ml index a60a168af9..421ffc6100 100644 --- a/jscomp/js_config.ml +++ b/jscomp/js_config.ml @@ -102,3 +102,27 @@ let runtime_set = String_set.of_list [ "caml_lexer.js"; "caml_string.js" ] + + +let prim = "Caml_primitive" + +let exceptions = "Caml_exceptions" + +let io = "Caml_io" + +let sys = "Caml_sys" + +let lex_parse = "Caml_lexer" + +let obj_runtime = "Caml_obj_runtime" + +let array = "Caml_array" + +let format = "Caml_format" + +let string = "Caml_string" + +let float = "Caml_float" + +let oo = "Caml_oo" +let curry = "Caml_curry" diff --git a/jscomp/js_config.mli b/jscomp/js_config.mli index 10d258476f..fd8b3913f6 100644 --- a/jscomp/js_config.mli +++ b/jscomp/js_config.mli @@ -30,4 +30,29 @@ val set_env : env -> unit val runtime_set : String_set.t val stdlib_set : String_set.t +val prim : string + +val exceptions : string + +val io : string + +val oo : string + +val sys : string + +val lex_parse : string + +val obj_runtime : string + +val array : string + +val format : string + +val string : string + +val float : string + +val curry : string + + diff --git a/jscomp/js_dump.ml b/jscomp/js_dump.ml index dfb529e07d..03caa350d7 100644 --- a/jscomp/js_dump.ml +++ b/jscomp/js_dump.ml @@ -393,12 +393,24 @@ and | Call (e, el, info) -> let action () = P.group f 1 (fun _ -> - let () = - match info with - | {arity = NA } -> ipp_comment f (Some "!") - | _ -> () in - let cxt = expression 15 cxt f e in - P.paren_group f 1 (fun _ -> arguments cxt f el ) ) + + match info with + | {arity = NA } -> + (* ipp_comment f (Some "!") *) + P.string f Js_config.curry; + P.string f L.dot; + let len = List.length el in + if len <= 8 then + begin + P.string f (Printf.sprintf "app%d" len); + P.paren_group f 1 (fun _ -> arguments cxt f (e::el)) + end + else assert false (* TODO *) + (* let cxt = expression 15 cxt f e in *) + (* P.paren_group f 1 (fun _ -> arguments cxt f el ) ) *) + | _ -> + let cxt = expression 15 cxt f e in + P.paren_group f 1 (fun _ -> arguments cxt f el ) ) in if l > 15 then P.paren_group f 1 action else action () diff --git a/jscomp/js_fold_basic.ml b/jscomp/js_fold_basic.ml index 5c01c1ec54..6bd4ed57cb 100644 --- a/jscomp/js_fold_basic.ml +++ b/jscomp/js_fold_basic.ml @@ -54,7 +54,16 @@ class count_hard_dependencies = | Qualified (id,kind,_) -> Hash_set.add hard_dependencies (Lam_module_ident.mk kind id); self | Id id -> self - + method! expression x = + match x with + | {expression_desc = Call (_,_, {arity = NA}); _} + (* see [Js_helper.Exp.runtime_var_dot] *) + -> begin + Hash_set.add hard_dependencies + (Lam_module_ident.of_runtime (Ext_ident.create_js Js_config.curry)); + super#expression x + end + | _ -> super#expression x method get_hard_dependencies = hard_dependencies end diff --git a/jscomp/js_helper.ml b/jscomp/js_helper.ml index 790d3ec7e7..ac7c534497 100644 --- a/jscomp/js_helper.ml +++ b/jscomp/js_helper.ml @@ -18,30 +18,6 @@ (* Author: Hongbo Zhang *) - - -let prim = "Caml_primitive" - -let exceptions = "Caml_exceptions" - -let io = "Caml_io" - -let sys = "Caml_sys" - -let lex_parse = "Caml_lexer" - -let obj_runtime = "Caml_obj_runtime" - -let array = "Caml_array" - -let format = "Caml_format" - -let string = "Caml_string" - -let float = "Caml_float" - -let oo = "Caml_oo" - let no_side_effect = Js_analyzer.no_side_effect_expression type binary_op = ?comment:string -> J.expression -> J.expression -> J.expression diff --git a/jscomp/js_helper.mli b/jscomp/js_helper.mli index 5e96b7f89e..c203a7cbf0 100644 --- a/jscomp/js_helper.mli +++ b/jscomp/js_helper.mli @@ -22,27 +22,7 @@ (** Creator utilities for the [J] module *) -val prim : string -val exceptions : string - -val io : string - -val oo : string - -val sys : string - -val lex_parse : string - -val obj_runtime : string - -val array : string - -val format : string - -val string : string - -val float : string val no_side_effect : J.expression -> bool diff --git a/jscomp/js_of_lam_string.ml b/jscomp/js_of_lam_string.ml index 695c18d082..efa04da573 100644 --- a/jscomp/js_of_lam_string.ml +++ b/jscomp/js_of_lam_string.ml @@ -67,10 +67,10 @@ module A = struct *) let bytes_to_string e = - E.runtime_call Js_helper.string "bytes_to_string" [e] + E.runtime_call Js_config.string "bytes_to_string" [e] let bytes_of_string s = - E.runtime_call Js_helper.string "bytes_of_string" [s] + E.runtime_call Js_config.string "bytes_of_string" [s] end (* We use module B for string compilation, once the upstream can make changes to the @@ -120,10 +120,10 @@ module B = struct *) let bytes_to_string e = - E.runtime_call Js_helper.string "bytes_to_string" [e] + E.runtime_call Js_config.string "bytes_to_string" [e] let bytes_of_string s = - E.runtime_call Js_helper.string "bytes_of_string" [s] + E.runtime_call Js_config.string "bytes_of_string" [s] end (* include A *) diff --git a/jscomp/lam_compile.ml b/jscomp/lam_compile.ml index c1a2be4821..afdb84a65b 100644 --- a/jscomp/lam_compile.ml +++ b/jscomp/lam_compile.ml @@ -122,7 +122,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_helper.prim "caml_update_dummy" [ E.var id; v])]), + b @ [S.exp(E.runtime_call Js_config.prim "caml_update_dummy" [ E.var id; v])]), [id] (* S.define ~kind:Variable id (E.arr Mutable []):: *) | _ -> assert false @@ -1143,7 +1143,7 @@ and | Cached | Public None (* TODO: check -- 1. js object propagate 2. js object create *) -> - let get = E.runtime_ref Js_helper.oo "caml_get_public_method" in + let get = E.runtime_ref Js_config.oo "caml_get_public_method" in let cache = !method_cache_id in let () = begin @@ -1207,7 +1207,7 @@ and end in (* Js_output.make [S.unknown_lambda lam] ~value:(E.unit ()) *) Js_output.handle_block_return st should_return lam (List.concat args_code) - (E.call (E.runtime_call Js_helper.oo "caml_get_public_method" + (E.call (E.runtime_call Js_config.oo "caml_get_public_method" [obj'; label; E.int cache]) (obj'::args)) (* avoid duplicated compuattion *) end diff --git a/jscomp/lam_compile_global.ml b/jscomp/lam_compile_global.ml index 3e4e9f7ba3..87a80e80b6 100644 --- a/jscomp/lam_compile_global.ml +++ b/jscomp/lam_compile_global.ml @@ -66,7 +66,7 @@ let get_exp (key : Lam_compile_env.key) : J.expression = if Ident.is_predef_exn id then begin - E.runtime_ref Js_helper.exceptions id.name + E.runtime_ref Js_config.exceptions id.name end else Lam_compile_env.query_and_add_if_not_exist (Lam_module_ident.of_ml id) env diff --git a/jscomp/lam_compile_group.ml b/jscomp/lam_compile_group.ml index 5cf1c3dede..64a6265bd3 100644 --- a/jscomp/lam_compile_group.ml +++ b/jscomp/lam_compile_group.ml @@ -41,7 +41,7 @@ let compile_group ({filename = file_name; env;} as meta : Lam_stats.meta) | Single(_, ({name="stdout"|"stderr"|"stdin";_} as id),_ ), "pervasives.ml" -> Js_output.of_stmt @@ S.alias_variable id - ~exp:(E.runtime_ref Js_helper.io id.name) + ~exp:(E.runtime_ref Js_config.io id.name) (* we delegate [stdout, stderr, and stdin] into [caml_io] module, the motivation is to help dead code eliminatiion, it's helpful diff --git a/jscomp/lam_dispatch_primitive.ml b/jscomp/lam_dispatch_primitive.ml index 801dac54a9..0cd44e8840 100644 --- a/jscomp/lam_dispatch_primitive.ml +++ b/jscomp/lam_dispatch_primitive.ml @@ -263,7 +263,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_hypot_float" -> - E.runtime_call Js_helper.float prim.prim_name args + E.runtime_call Js_config.float prim.prim_name args | "caml_fmod_float" (* float module like js number module *) -> @@ -329,7 +329,7 @@ let query (prim : Lam_compile_env.primitive_description) E.uninitialized_array v (* TODO: inline and spits out a warning when i is negative *) | _ -> - E.runtime_call Js_helper.string prim.prim_name args + E.runtime_call Js_config.string prim.prim_name args end | "caml_string_get" @@ -343,7 +343,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_blit_string" | "caml_blit_bytes" -> - E.runtime_call Js_helper.string prim.prim_name args + E.runtime_call Js_config.string prim.prim_name args | "caml_register_named_value" -> (** @@ -423,12 +423,12 @@ let query (prim : Lam_compile_env.primitive_description) ([ tag; str ; E.prefix_inc (E.runtime_var_vid - Js_helper.exceptions + Js_config.exceptions "caml_oo_last_id") ], flag) } | _ -> - E.runtime_call Js_helper.exceptions prim.prim_name args + E.runtime_call Js_config.exceptions prim.prim_name args end | "caml_sys_const_big_endian" -> @@ -455,12 +455,12 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_sys_random_seed" | "caml_sys_getenv" | "caml_sys_system_command" -> - E.runtime_call Js_helper.sys prim.prim_name args + E.runtime_call Js_config.sys prim.prim_name args | "caml_lex_engine" | "caml_new_lex_engine" | "caml_parse_engine" | "caml_set_parser_trace" -> - E.runtime_call Js_helper.lex_parse prim.prim_name args + E.runtime_call Js_config.lex_parse prim.prim_name args | "caml_array_sub" | "caml_array_concat" @@ -469,7 +469,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_array_blit" | "caml_make_vect" -> - E.runtime_call Js_helper.array prim.prim_name args + E.runtime_call Js_config.array prim.prim_name args | "caml_ml_flush" | "caml_ml_out_channels_list" | "caml_ml_open_descriptor_in" @@ -478,7 +478,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_ml_output" | "caml_ml_input_char" -> - E.runtime_call Js_helper.io prim.prim_name args + E.runtime_call Js_config.io prim.prim_name args | "caml_obj_dup" -> (** Note currently is an Array copy function, this is tightly coupled with @@ -490,7 +490,7 @@ let query (prim : Lam_compile_env.primitive_description) match args with | [ a ] when Js_helper.is_constant a -> a | _ -> - E.runtime_call Js_helper.obj_runtime prim.prim_name args + E.runtime_call Js_config.obj_runtime prim.prim_name args end | "caml_obj_block" -> (** TODO: Optimize for [CamlinternalOO] input @@ -504,7 +504,7 @@ let query (prim : Lam_compile_env.primitive_description) {expression_desc = Number (Int { i = 0;_}); _} ] -> E.arr Immutable [E.int tag] (** size 0*) | _ -> - E.runtime_call Js_helper.obj_runtime prim.prim_name args + E.runtime_call Js_config.obj_runtime prim.prim_name args end | "caml_obj_is_block" @@ -514,7 +514,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_obj_truncate" | "caml_lazy_make_forward" -> - E.runtime_call Js_helper.obj_runtime prim.prim_name args + E.runtime_call Js_config.obj_runtime prim.prim_name args | "caml_format_float" | "caml_format_int" @@ -524,7 +524,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_int_of_string" (* what is the semantics?*) | "caml_int32_of_string" | "caml_nativeint_of_string" -> - E.runtime_call Js_helper.format prim.prim_name args + E.runtime_call Js_config.format prim.prim_name args (* "caml_alloc_dummy"; *) @@ -549,10 +549,10 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_int32_bswap" | "caml_nativeint_bswap" | "caml_int64_bswap" - -> E.runtime_call Js_helper.prim prim.prim_name args + -> E.runtime_call Js_config.prim prim.prim_name args | "caml_get_public_method" -> - E.runtime_call Js_helper.oo prim.prim_name args + E.runtime_call Js_config.oo prim.prim_name args (** TODO: Primitives not implemented yet ...*) | "caml_install_signal_handler" | "caml_output_value_to_buffer" @@ -596,7 +596,7 @@ let query (prim : Lam_compile_env.primitive_description) | "caml_ml_seek_out_64" | "caml_ml_set_binary_mode" | "caml_sys_getcwd" (* check browser or nodejs *) - -> E.runtime_call Js_helper.prim prim.prim_name args + -> E.runtime_call Js_config.prim prim.prim_name args | "js_function_length" diff --git a/jscomp/runtime/.depend b/jscomp/runtime/.depend index dc7821ddf5..4d603f1b86 100644 --- a/jscomp/runtime/.depend +++ b/jscomp/runtime/.depend @@ -3,17 +3,17 @@ caml_oo.cmi : caml_string.cmi : caml_array.cmo : caml_array.cmi caml_array.cmx : caml_array.cmi +caml_curry.cmo : +caml_curry.cmx : caml_oo.cmo : caml_oo.cmi caml_oo.cmx : caml_oo.cmi caml_string.cmo : caml_string.cmi caml_string.cmx : caml_string.cmi -curry.cmo : -curry.cmx : caml_array.cmo : caml_array.cmi caml_array.cmj : caml_array.cmi +caml_curry.cmo : +caml_curry.cmj : caml_oo.cmo : caml_oo.cmi caml_oo.cmj : caml_oo.cmi caml_string.cmo : caml_string.cmi caml_string.cmj : caml_string.cmi -curry.cmo : -curry.cmj : diff --git a/jscomp/runtime/caml_curry.d.ts b/jscomp/runtime/caml_curry.d.ts new file mode 100644 index 0000000000..211a328dc5 --- /dev/null +++ b/jscomp/runtime/caml_curry.d.ts @@ -0,0 +1,18 @@ +export var curry: (f : any, args : any) => any ; +export var curry1: (o : any, x : any, arity : any) => any ; +export var app1: (o : any, x : any) => any ; +export var app2: (o : any, x : any, y : any) => any ; +export var app3: (o : any, a0 : any, a1 : any, a2 : any) => any ; +export var app4: (o : any, a0 : any, a1 : any, a2 : any, a3 : any) => any ; +export var app5: + (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any) => any ; +export var app6: + (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any, a5 : any) => + any ; +export var app7: + (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any, a5 : any, + a6 : any) => any ; +export var app8: + (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any, a5 : any, + a6 : any, a7 : any) => any ; + diff --git a/jscomp/runtime/caml_curry.js b/jscomp/runtime/caml_curry.js new file mode 100644 index 0000000000..85b19d1ff3 --- /dev/null +++ b/jscomp/runtime/caml_curry.js @@ -0,0 +1,207 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_array = require("./caml_array"); + +function curry(_f, _args) { + while(true) { + var args = _args; + var f = _f; + var arity = f.length; + var len = args.length; + var d = arity - len; + if (d) { + if (d < 0) { + _args = Caml_array.caml_array_sub(args, arity, -d); + _f = f.apply(null, Caml_array.caml_array_sub(args, 0, arity)); + } + else { + return (function(f,args){ + return function (x) { + return curry(f, args.concat(/* array */[x])); + } + }(f,args)); + } + } + else { + return f.apply(null, args); + } + }; +} + +function curry1(o, x, arity) { + if (arity > 7 || arity < 0) { + return function (a) { + return curry(o, /* array */[ + x, + a + ]); + }; + } + else { + switch (arity) { + case 0 : + case 1 : + return o(x); + case 2 : + return function (param) { + return o(x, param); + }; + case 3 : + return function (param, param$1) { + return o(x, param, param$1); + }; + case 4 : + return function (param, param$1, param$2) { + return o(x, param, param$1, param$2); + }; + case 5 : + return function (param, param$1, param$2, param$3) { + return o(x, param, param$1, param$2, param$3); + }; + case 6 : + return function (param, param$1, param$2, param$3, param$4) { + return o(x, param, param$1, param$2, param$3, param$4); + }; + case 7 : + return function (param, param$1, param$2, param$3, param$4, param$5) { + return o(x, param, param$1, param$2, param$3, param$4, param$5); + }; + + } + } +} + +function app1(o, x) { + var len = o.length; + if (len === 1 || len === 0) { + return o(x); + } + else { + return curry1(o, x, len); + } +} + +function app2(o, x, y) { + var len = o.length; + if (len === 2) { + return o(x, y); + } + else { + return curry(o, /* array */[ + x, + y + ]); + } +} + +function app3(o, a0, a1, a2) { + var len = o.length; + if (len === 3) { + return o(a0, a1, a2); + } + else { + return curry(o, /* array */[ + a0, + a1, + a2 + ]); + } +} + +function app4(o, a0, a1, a2, a3) { + var len = o.length; + if (len === 4) { + return o(a0, a1, a2, a3); + } + else { + return curry(o, /* array */[ + a0, + a1, + a2, + a3 + ]); + } +} + +function app5(o, a0, a1, a2, a3, a4) { + var len = o.length; + if (len === 5) { + return o(a0, a1, a2, a3, a4); + } + else { + return curry(o, /* array */[ + a0, + a1, + a2, + a3, + a4 + ]); + } +} + +function app6(o, a0, a1, a2, a3, a4, a5) { + var len = o.length; + if (len === 6) { + return o(a0, a1, a2, a3, a4, a5); + } + else { + return curry(o, /* array */[ + a0, + a1, + a2, + a3, + a4, + a5 + ]); + } +} + +function app7(o, a0, a1, a2, a3, a4, a5, a6) { + var len = o.length; + if (len === 7) { + return o(a0, a1, a2, a3, a4, a5, a6); + } + else { + return curry(o, /* array */[ + a0, + a1, + a2, + a3, + a4, + a5, + a6 + ]); + } +} + +function app8(o, a0, a1, a2, a3, a4, a5, a6, a7) { + var len = o.length; + if (len === 8) { + return o(a0, a1, a2, a3, a4, a5, a6, a7); + } + else { + return curry(o, /* array */[ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7 + ]); + } +} + +exports.curry = curry; +exports.curry1 = curry1; +exports.app1 = app1; +exports.app2 = app2; +exports.app3 = app3; +exports.app4 = app4; +exports.app5 = app5; +exports.app6 = app6; +exports.app7 = app7; +exports.app8 = app8; +/* No side effect */ diff --git a/jscomp/runtime/curry.ml b/jscomp/runtime/caml_curry.ml similarity index 100% rename from jscomp/runtime/curry.ml rename to jscomp/runtime/caml_curry.ml diff --git a/jscomp/runtime/runtime.mllib b/jscomp/runtime/runtime.mllib index 104fd32668..7bbde9346d 100644 --- a/jscomp/runtime/runtime.mllib +++ b/jscomp/runtime/runtime.mllib @@ -1,4 +1,4 @@ -curry +caml_curry caml_array caml_string caml_oo \ No newline at end of file diff --git a/jscomp/stdlib/arg.js b/jscomp/stdlib/arg.js index f18c3568c5..d5bc66fda4 100644 --- a/jscomp/stdlib/arg.js +++ b/jscomp/stdlib/arg.js @@ -8,6 +8,7 @@ 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"); @@ -124,19 +125,19 @@ function add_help(speclist) { } function usage_b(buf, speclist, errmsg) { - Printf.bprintf(buf, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app1(Printf.bprintf(buf, [ + /* Format */0, [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ], - "%s\n" - ])(errmsg); + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] + ], + "%s\n" + ]), errmsg); return List.iter(function (param) { var buf$1 = buf; var param$1 = param; @@ -145,62 +146,62 @@ function usage_b(buf, speclist, errmsg) { var key = param$1[1]; if (doc.length) { if (spec[0] === 11) { - return Printf.bprintf(buf$1, [ - /* Format */0, - [ - /* String_literal */11, - " ", + return Caml_curry.app3(Printf.bprintf(buf$1, [ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + " ", [ - /* Char_literal */12, - /* " " */32, + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* Char_literal */12, + /* " " */32, [ /* String */2, /* No_padding */0, [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */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); + ], + " %s %s%s\n" + ]), key, make_symlist("{", "|", "}", spec[1]), doc); } else { - return Printf.bprintf(buf$1, [ - /* Format */0, - [ - /* String_literal */11, - " ", + return Caml_curry.app2(Printf.bprintf(buf$1, [ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + " ", [ - /* Char_literal */12, - /* " " */32, + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* Char_literal */12, + /* " " */32, [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] ] ] ] - ] - ], - " %s %s\n" - ])(key, doc); + ], + " %s %s\n" + ]), key, doc); } } else { @@ -216,15 +217,15 @@ function usage_string(speclist, errmsg) { } function usage(speclist, errmsg) { - return 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 */2, + /* No_padding */0, + /* End_of_format */0 + ], + "%s" + ]), usage_string(speclist, errmsg)); } var current = [ @@ -247,113 +248,113 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { case "-help" : break; default: - Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app2(Printf.bprintf(b, [ + /* Format */0, [ - /* String_literal */11, - ": unknown option '", + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ": unknown option '", [ - /* String_literal */11, - "'.\n", - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* String_literal */11, + "'.\n", + /* End_of_format */0 + ] ] ] - ] - ], - "%s: unknown option '%s'.\n" - ])(progname, s); + ], + "%s: unknown option '%s'.\n" + ]), progname, s); } break; case 1 : - Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app4(Printf.bprintf(b, [ + /* Format */0, [ - /* String_literal */11, - ": wrong argument '", + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ": wrong argument '", [ - /* String_literal */11, - "'; option '", + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "'; option '", [ - /* String_literal */11, - "' expects ", + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "' expects ", [ - /* String_literal */11, - ".\n", - /* End_of_format */0 + /* 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]); + ], + "%s: wrong argument '%s'; option '%s' expects %s.\n" + ]), progname, error[2], error[1], error[3]); break; case 2 : - Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app2(Printf.bprintf(b, [ + /* Format */0, [ - /* String_literal */11, - ": option '", + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ": option '", [ - /* String_literal */11, - "' needs an argument.\n", - /* End_of_format */0 + /* 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]); + ], + "%s: option '%s' needs an argument.\n" + ]), progname, error[1]); break; case 3 : - Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app2(Printf.bprintf(b, [ + /* Format */0, [ - /* String_literal */11, - ": ", + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ": ", [ - /* String_literal */11, - ".\n", - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* String_literal */11, + ".\n", + /* End_of_format */0 + ] ] ] - ] - ], - "%s: %s.\n" - ])(progname, error[1]); + ], + "%s: %s.\n" + ]), progname, error[1]); break; } @@ -403,12 +404,12 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { return function (param) { switch (param[0]) { case 0 : - return param[1](/* () */0); + return Caml_curry.app1(param[1], /* () */0); case 1 : if (current$1[1] + 1 < l) { var arg = argv[current$1[1] + 1]; try { - param[1](Pervasives.bool_of_string(arg)); + Caml_curry.app1(param[1], Pervasives.bool_of_string(arg)); } catch (exn){ if (exn[1] === Caml_exceptions.Invalid_argument) { @@ -453,7 +454,7 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { return /* () */0; case 4 : if (current$1[1] + 1 < l) { - param[1](argv[current$1[1] + 1]); + Caml_curry.app1(param[1], argv[current$1[1] + 1]); return ++ current$1[1]; } else { @@ -487,7 +488,7 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { if (current$1[1] + 1 < l) { var arg$1 = argv[current$1[1] + 1]; try { - param[1](Caml_format.caml_int_of_string(arg$1)); + Caml_curry.app1(param[1], Caml_format.caml_int_of_string(arg$1)); } catch (exn$1){ if (exn$1[1] === Caml_exceptions.Failure) { @@ -569,7 +570,7 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { if (current$1[1] + 1 < l) { var arg$3 = argv[current$1[1] + 1]; try { - param[1](Caml_format.caml_float_of_string(arg$3)); + Caml_curry.app1(param[1], Caml_format.caml_float_of_string(arg$3)); } catch (exn$3){ if (exn$3[1] === Caml_exceptions.Failure) { @@ -654,7 +655,7 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { if (current$1[1] + 1 < l) { var arg$5 = argv[current$1[1] + 1]; if (List.mem(arg$5, symb)) { - param[2](argv[current$1[1] + 1]); + Caml_curry.app1(param[2], argv[current$1[1] + 1]); return ++ current$1[1]; } else { @@ -684,7 +685,7 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { case 12 : var f = param[1]; while(current$1[1] < l - 1) { - f(argv[current$1[1] + 1]); + Caml_curry.app1(f, argv[current$1[1] + 1]); ++ current$1[1]; }; return /* () */0; @@ -712,7 +713,7 @@ function parse_argv_dynamic($staropt$star, argv, speclist, anonfun, errmsg) { } else { try { - anonfun(s); + Caml_curry.app1(anonfun, s); } catch (exn$2){ if (exn$2[1] === Bad) { @@ -748,27 +749,27 @@ function parse(l, f, msg) { } catch (exn){ if (exn[1] === Bad) { - Printf.eprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ])(exn[2]); + Caml_curry.app1(Printf.eprintf([ + /* Format */0, + [ + /* String */2, + /* No_padding */0, + /* End_of_format */0 + ], + "%s" + ]), exn[2]); return Pervasives.exit(2); } else if (exn[1] === Help) { - Printf.printf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ])(exn[2]); + Caml_curry.app1(Printf.printf([ + /* Format */0, + [ + /* String */2, + /* No_padding */0, + /* End_of_format */0 + ], + "%s" + ]), exn[2]); return Pervasives.exit(0); } else { @@ -783,27 +784,27 @@ function parse_dynamic(l, f, msg) { } catch (exn){ if (exn[1] === Bad) { - Printf.eprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ])(exn[2]); + Caml_curry.app1(Printf.eprintf([ + /* Format */0, + [ + /* String */2, + /* No_padding */0, + /* End_of_format */0 + ], + "%s" + ]), exn[2]); return Pervasives.exit(2); } else if (exn[1] === Help) { - Printf.printf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ], - "%s" - ])(exn[2]); + Caml_curry.app1(Printf.printf([ + /* Format */0, + [ + /* String */2, + /* No_padding */0, + /* End_of_format */0 + ], + "%s" + ]), exn[2]); return Pervasives.exit(0); } else { diff --git a/jscomp/stdlib/array.js b/jscomp/stdlib/array.js index 546658bad3..d6674fea67 100644 --- a/jscomp/stdlib/array.js +++ b/jscomp/stdlib/array.js @@ -4,6 +4,7 @@ var Pervasives = require("./pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_array = require("../runtime/caml_array"); +var Caml_curry = require("../runtime/caml_curry"); function init(l, f) { if (l) { @@ -11,9 +12,9 @@ function init(l, f) { return Pervasives.invalid_arg("Array.init"); } else { - var res = Caml_array.caml_make_vect(l, f(0)); + var res = Caml_array.caml_make_vect(l, Caml_curry.app1(f, 0)); for(var i = 1 ,i_finish = l - 1; i<= i_finish; ++i){ - res[i] = f(i); + res[i] = Caml_curry.app1(f, i); } return res; } @@ -88,7 +89,7 @@ function blit(a1, ofs1, a2, ofs2, len) { function iter(f, a) { for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ - f(a[i]); + Caml_curry.app1(f, a[i]); } return /* () */0; } @@ -96,9 +97,9 @@ function iter(f, a) { function map(f, a) { var l = a.length; if (l) { - var r = Caml_array.caml_make_vect(l, f(a[0])); + var r = Caml_array.caml_make_vect(l, Caml_curry.app1(f, a[0])); for(var i = 1 ,i_finish = l - 1; i<= i_finish; ++i){ - r[i] = f(a[i]); + r[i] = Caml_curry.app1(f, a[i]); } return r; } @@ -109,7 +110,7 @@ function map(f, a) { function iteri(f, a) { for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ - f(i, a[i]); + Caml_curry.app2(f, i, a[i]); } return /* () */0; } @@ -117,9 +118,9 @@ function iteri(f, a) { function mapi(f, a) { var l = a.length; if (l) { - var r = Caml_array.caml_make_vect(l, f(0, a[0])); + var r = Caml_array.caml_make_vect(l, Caml_curry.app2(f, 0, a[0])); for(var i = 1 ,i_finish = l - 1; i<= i_finish; ++i){ - r[i] = f(i, a[i]); + r[i] = Caml_curry.app2(f, i, a[i]); } return r; } @@ -188,7 +189,7 @@ function of_list(l) { function fold_left(f, x, a) { var r = x; for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ - r = f(r, a[i]); + r = Caml_curry.app2(f, r, a[i]); } return r; } @@ -196,7 +197,7 @@ function fold_left(f, x, a) { function fold_right(f, a, x) { var r = x; for(var i = a.length - 1; i>= 0; --i){ - r = f(a[i], r); + r = Caml_curry.app2(f, a[i], r); } return r; } @@ -212,15 +213,15 @@ function sort(cmp, a) { var i31 = i + i + i + 1; var x = i31; if (i31 + 2 < l) { - if (cmp(a[i31], a[i31 + 1]) < 0) { + if (Caml_curry.app2(cmp, a[i31], a[i31 + 1]) < 0) { x = i31 + 1; } - if (cmp(a[x], a[i31 + 2]) < 0) { + if (Caml_curry.app2(cmp, a[x], a[i31 + 2]) < 0) { x = i31 + 2; } return x; } - else if (i31 + 1 < l && cmp(a[i31], a[i31 + 1]) < 0) { + else if (i31 + 1 < l && Caml_curry.app2(cmp, a[i31], a[i31 + 1]) < 0) { return i31 + 1; } else if (i31 < l) { @@ -242,7 +243,7 @@ function sort(cmp, a) { while(true) { var i$1 = _i; var j = maxson(l$1, i$1); - if (cmp(a[j], e$1) > 0) { + if (Caml_curry.app2(cmp, a[j], e$1) > 0) { a[i$1] = a[j]; _i = j; } @@ -298,7 +299,7 @@ function sort(cmp, a) { ] ]; } - if (cmp(a[father], e) < 0) { + if (Caml_curry.app2(cmp, a[father], e) < 0) { a[i] = a[father]; if (father > 0) { _i = father; @@ -351,7 +352,7 @@ function stable_sort(cmp, a) { var i2 = _i2; var s1 = _s1; var i1 = _i1; - if (cmp(s1, s2) <= 0) { + if (Caml_curry.app2(cmp, s1, s2) <= 0) { dst[d] = s1; var i1$1 = i1 + 1; if (i1$1 < src1r) { @@ -381,7 +382,7 @@ function stable_sort(cmp, a) { for(var i = 0 ,i_finish = len - 1; i<= i_finish; ++i){ var e = a[srcofs + i]; var j = dstofs + i - 1; - while(j >= dstofs && cmp(dst[j], e) > 0) { + while(j >= dstofs && Caml_curry.app2(cmp, dst[j], e) > 0) { dst[j + 1] = dst[j]; -- j; }; diff --git a/jscomp/stdlib/buffer.js b/jscomp/stdlib/buffer.js index 417fdc781b..2b9ce67eef 100644 --- a/jscomp/stdlib/buffer.js +++ b/jscomp/stdlib/buffer.js @@ -5,6 +5,7 @@ var Bytes = require("./bytes"); var Pervasives = require("./pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Sys = require("./sys"); +var Caml_curry = require("../runtime/caml_curry"); var $$String = require("./string"); var Caml_string = require("../runtime/caml_string"); @@ -117,7 +118,7 @@ function add_substring(b, s, offset, len) { } function add_subbytes(b, s, offset, len) { - return add_substring(b, Bytes.unsafe_to_string(s), offset, len); + return add_substring(b, Caml_curry.app1(Bytes.unsafe_to_string, s), offset, len); } function add_string(b, s) { @@ -132,7 +133,7 @@ function add_string(b, s) { } function add_bytes(b, s) { - return add_string(b, Bytes.unsafe_to_string(s)); + return add_string(b, Caml_curry.app1(Bytes.unsafe_to_string, s)); } function add_buffer(b, bs) { @@ -326,7 +327,7 @@ function add_substitute(b, f, s) { else { var j = i + 1; var match = find_ident(s, j, lim); - add_string(b, f(match[1])); + add_string(b, Caml_curry.app1(f, match[1])); _i = match[2]; _previous = /* " " */32; } diff --git a/jscomp/stdlib/bytes.js b/jscomp/stdlib/bytes.js index 324c78b740..ecf83a4f26 100644 --- a/jscomp/stdlib/bytes.js +++ b/jscomp/stdlib/bytes.js @@ -5,6 +5,7 @@ var Pervasives = require("./pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); 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"); @@ -17,7 +18,7 @@ function make(n, c) { function init(n, f) { var s = Caml_string.caml_create_string(n); for(var i = 0 ,i_finish = n - 1; i<= i_finish; ++i){ - s[i] = f(i); + s[i] = Caml_curry.app1(f, i); } return s; } @@ -104,14 +105,14 @@ function blit_string(s1, ofs1, s2, ofs2, len) { function iter(f, a) { for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ - f(a[i]); + Caml_curry.app1(f, a[i]); } return /* () */0; } function iteri(f, a) { for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ - f(i, a[i]); + Caml_curry.app2(f, i, a[i]); } return /* () */0; } @@ -310,7 +311,7 @@ function map(f, s) { if (l) { var r = Caml_string.caml_create_string(l); for(var i = 0 ,i_finish = l - 1; i<= i_finish; ++i){ - r[i] = f(s[i]); + r[i] = Caml_curry.app1(f, s[i]); } return r; } @@ -324,7 +325,7 @@ function mapi(f, s) { if (l) { var r = Caml_string.caml_create_string(l); for(var i = 0 ,i_finish = l - 1; i<= i_finish; ++i){ - r[i] = f(i, s[i]); + r[i] = Caml_curry.app2(f, i, s[i]); } return r; } @@ -344,7 +345,7 @@ function lowercase(s) { function apply1(f, s) { if (s.length) { var r = copy(s); - r[0] = f(s[0]); + r[0] = Caml_curry.app1(f, s[0]); return r; } else { diff --git a/jscomp/stdlib/camlinternalFormat.js b/jscomp/stdlib/camlinternalFormat.js index bbc22f41c4..420e0f28f8 100644 --- a/jscomp/stdlib/camlinternalFormat.js +++ b/jscomp/stdlib/camlinternalFormat.js @@ -11,6 +11,7 @@ var Sys = require("./sys"); var Caml_primitive = require("../runtime/caml_primitive"); var CamlinternalFormatBasics = require("./camlinternalFormatBasics"); var Buffer = require("./buffer"); +var Caml_curry = require("../runtime/caml_curry"); var $$String = require("./string"); var Caml_string = require("../runtime/caml_string"); @@ -34,7 +35,7 @@ function rev_char_set(char_set) { for(var i = 0; i<= 31; ++i){ char_set$prime[i] = Pervasives.char_of_int(char_set.charCodeAt(i) ^ 255); } - return Bytes.unsafe_to_string(char_set$prime); + return Caml_curry.app1(Bytes.unsafe_to_string, char_set$prime); } function is_in_char_set(char_set, c) { @@ -1053,11 +1054,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa(/* Refl */0); + Caml_curry.app1(fa, /* Refl */0); return /* Refl */0; }, function () { - af(/* Refl */0); + Caml_curry.app1(af, /* Refl */0); return /* Refl */0; }, match[3], @@ -1070,11 +1071,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$1(/* Refl */0); + Caml_curry.app1(fa$1, /* Refl */0); return /* Refl */0; }, function () { - af$1(/* Refl */0); + Caml_curry.app1(af$1, /* Refl */0); return /* Refl */0; }, match$1[3], @@ -1087,11 +1088,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$2(/* Refl */0); + Caml_curry.app1(fa$2, /* Refl */0); return /* Refl */0; }, function () { - af$2(/* Refl */0); + Caml_curry.app1(af$2, /* Refl */0); return /* Refl */0; }, match$2[3], @@ -1104,11 +1105,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$3(/* Refl */0); + Caml_curry.app1(fa$3, /* Refl */0); return /* Refl */0; }, function () { - af$3(/* Refl */0); + Caml_curry.app1(af$3, /* Refl */0); return /* Refl */0; }, match$3[3], @@ -1121,11 +1122,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$4(/* Refl */0); + Caml_curry.app1(fa$4, /* Refl */0); return /* Refl */0; }, function () { - af$4(/* Refl */0); + Caml_curry.app1(af$4, /* Refl */0); return /* Refl */0; }, match$4[3], @@ -1138,11 +1139,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$5(/* Refl */0); + Caml_curry.app1(fa$5, /* Refl */0); return /* Refl */0; }, function () { - af$5(/* Refl */0); + Caml_curry.app1(af$5, /* Refl */0); return /* Refl */0; }, match$5[3], @@ -1155,11 +1156,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$6(/* Refl */0); + Caml_curry.app1(fa$6, /* Refl */0); return /* Refl */0; }, function () { - af$6(/* Refl */0); + Caml_curry.app1(af$6, /* Refl */0); return /* Refl */0; }, match$6[3], @@ -1172,11 +1173,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$7(/* Refl */0); + Caml_curry.app1(fa$7, /* Refl */0); return /* Refl */0; }, function () { - af$7(/* Refl */0); + Caml_curry.app1(af$7, /* Refl */0); return /* Refl */0; }, match$7[3], @@ -1189,11 +1190,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$8(/* Refl */0); + Caml_curry.app1(fa$8, /* Refl */0); return /* Refl */0; }, function () { - af$8(/* Refl */0); + Caml_curry.app1(af$8, /* Refl */0); return /* Refl */0; }, match$8[3], @@ -1214,23 +1215,23 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$9(/* Refl */0); - ag(/* Refl */0); + Caml_curry.app1(fa$9, /* Refl */0); + Caml_curry.app1(ag, /* Refl */0); return /* Refl */0; }, function () { - ga(/* Refl */0); - af$9(/* Refl */0); + Caml_curry.app1(ga, /* Refl */0); + Caml_curry.app1(af$9, /* Refl */0); return /* Refl */0; }, function () { - ed(/* Refl */0); - dj(/* Refl */0); + Caml_curry.app1(ed, /* Refl */0); + Caml_curry.app1(dj, /* Refl */0); return /* Refl */0; }, function () { - jd(/* Refl */0); - de(/* Refl */0); + Caml_curry.app1(jd, /* Refl */0); + Caml_curry.app1(de, /* Refl */0); return /* Refl */0; } ]; @@ -1241,11 +1242,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$10(/* Refl */0); + Caml_curry.app1(fa$10, /* Refl */0); return /* Refl */0; }, function () { - af$10(/* Refl */0); + Caml_curry.app1(af$10, /* Refl */0); return /* Refl */0; }, match$11[3], @@ -1258,11 +1259,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$11(/* Refl */0); + Caml_curry.app1(fa$11, /* Refl */0); return /* Refl */0; }, function () { - af$11(/* Refl */0); + Caml_curry.app1(af$11, /* Refl */0); return /* Refl */0; }, match$12[3], @@ -1275,11 +1276,11 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$12(/* Refl */0); + Caml_curry.app1(fa$12, /* Refl */0); return /* Refl */0; }, function () { - af$12(/* Refl */0); + Caml_curry.app1(af$12, /* Refl */0); return /* Refl */0; }, match$13[3], @@ -1294,19 +1295,19 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$13(/* Refl */0); + Caml_curry.app1(fa$13, /* Refl */0); return /* Refl */0; }, function () { - af$13(/* Refl */0); + Caml_curry.app1(af$13, /* Refl */0); return /* Refl */0; }, function () { - ed$1(/* Refl */0); + Caml_curry.app1(ed$1, /* Refl */0); return /* Refl */0; }, function () { - de$1(/* Refl */0); + Caml_curry.app1(de$1, /* Refl */0); return /* Refl */0; } ]; @@ -1319,19 +1320,19 @@ function fmtty_rel_det(param) { return [ /* tuple */0, function () { - fa$14(/* Refl */0); + Caml_curry.app1(fa$14, /* Refl */0); return /* Refl */0; }, function () { - af$14(/* Refl */0); + Caml_curry.app1(af$14, /* Refl */0); return /* Refl */0; }, function () { - ed$2(/* Refl */0); + Caml_curry.app1(ed$2, /* Refl */0); return /* Refl */0; }, function () { - de$2(/* Refl */0); + Caml_curry.app1(de$2, /* Refl */0); return /* Refl */0; } ]; @@ -1758,8 +1759,8 @@ function trans(ty1, ty2) { case 9 : var ty = trans(symm(ty1[2]), ty2[1]); var match = fmtty_rel_det(ty); - match[2](/* Refl */0); - match[4](/* Refl */0); + Caml_curry.app1(match[2], /* Refl */0); + Caml_curry.app1(match[4], /* Refl */0); return [ /* Format_subst_ty */9, ty1[1], @@ -3171,8 +3172,8 @@ function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { } var sub_fmtty$prime = trans(symm(sub1_fmtty$prime), sub2_fmtty$prime$1); var match$9 = fmtty_rel_det(sub_fmtty$prime); - match$9[2](/* Refl */0); - match$9[4](/* Refl */0); + 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, @@ -3309,7 +3310,7 @@ function fix_padding(padty, width, str) { break; } - return Bytes.unsafe_to_string(res); + return Caml_curry.app1(Bytes.unsafe_to_string, res); } } @@ -3350,7 +3351,7 @@ function fix_int_precision(prec, str) { var res = Bytes.make(prec$1 + 2, /* "0" */48); res[1] = str.charCodeAt(1); $$String.blit(str, 2, res, prec$1 - len + 4, len - 2); - return Bytes.unsafe_to_string(res); + return Caml_curry.app1(Bytes.unsafe_to_string, res); } else { exit = 2; @@ -3383,7 +3384,7 @@ function fix_int_precision(prec, str) { var res$1 = Bytes.make(prec$1 + 1, /* "0" */48); res$1[0] = c; $$String.blit(str, 1, res$1, prec$1 - len + 2, len - 1); - return Bytes.unsafe_to_string(res$1); + return Caml_curry.app1(Bytes.unsafe_to_string, res$1); } else { return str; @@ -3393,7 +3394,7 @@ function fix_int_precision(prec, str) { if (prec$1 > len) { var res$2 = Bytes.make(prec$1, /* "0" */48); $$String.blit(str, 0, res$2, prec$1 - len, len); - return Bytes.unsafe_to_string(res$2); + return Caml_curry.app1(Bytes.unsafe_to_string, res$2); } else { return str; @@ -3718,7 +3719,7 @@ function make_printf(_k, o, _acc, _fmt) { var acc = _acc; var k = _k; if (typeof fmt === "number") { - return k(o, acc); + return Caml_curry.app2(k, o, acc); } else { switch (fmt[0]) { @@ -3959,7 +3960,7 @@ function make_printf(_k, o, _acc, _fmt) { /* Acc_delay */6, acc, function (o) { - return f(o, x); + return Caml_curry.app2(f, o, x); } ], rest$5); } @@ -4116,7 +4117,7 @@ function make_printf(_k, o, _acc, _fmt) { } } case 24 : - return make_custom(k, o, acc, fmt[3], fmt[1], fmt[2](/* () */0)); + return make_custom(k, o, acc, fmt[3], fmt[1], Caml_curry.app1(fmt[2], /* () */0)); } } @@ -4233,7 +4234,7 @@ function make_invalid_arg(k, o, acc, fmt) { function make_string_padding(k, o, acc, fmt, pad, trans) { if (typeof pad === "number") { return function (x) { - var new_acc_002 = trans(x); + var new_acc_002 = Caml_curry.app1(trans, x); var new_acc = [ /* Acc_data_string */4, acc, @@ -4245,7 +4246,7 @@ function make_string_padding(k, o, acc, fmt, pad, trans) { else if (pad[0]) { var padty = pad[1]; return function (w, x) { - var new_acc_002 = fix_padding(padty, w, trans(x)); + var new_acc_002 = fix_padding(padty, w, Caml_curry.app1(trans, x)); var new_acc = [ /* Acc_data_string */4, acc, @@ -4258,7 +4259,7 @@ function make_string_padding(k, o, acc, fmt, pad, trans) { var width = pad[2]; var padty$1 = pad[1]; return function (x) { - var new_acc_002 = fix_padding(padty$1, width, trans(x)); + var new_acc_002 = fix_padding(padty$1, width, Caml_curry.app1(trans, x)); var new_acc = [ /* Acc_data_string */4, acc, @@ -4274,7 +4275,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { if (typeof prec === "number") { if (prec !== 0) { return function (p, x) { - var str = fix_int_precision(p, trans(iconv, x)); + var str = fix_int_precision(p, Caml_curry.app2(trans, iconv, x)); return make_printf(k, o, [ /* Acc_data_string */4, acc, @@ -4284,7 +4285,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { } else { return function (x) { - var str = trans(iconv, x); + var str = Caml_curry.app2(trans, iconv, x); return make_printf(k, o, [ /* Acc_data_string */4, acc, @@ -4296,7 +4297,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { else { var p = prec[1]; return function (x) { - var str = fix_int_precision(p, trans(iconv, x)); + var str = fix_int_precision(p, Caml_curry.app2(trans, iconv, x)); return make_printf(k, o, [ /* Acc_data_string */4, acc, @@ -4310,7 +4311,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { if (typeof prec === "number") { if (prec !== 0) { return function (w, p, x) { - var str = fix_padding(padty, w, fix_int_precision(p, trans(iconv, 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, @@ -4320,7 +4321,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { } else { return function (w, x) { - var str = fix_padding(padty, w, trans(iconv, x)); + var str = fix_padding(padty, w, Caml_curry.app2(trans, iconv, x)); return make_printf(k, o, [ /* Acc_data_string */4, acc, @@ -4332,7 +4333,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { else { var p$1 = prec[1]; return function (w, x) { - var str = fix_padding(padty, w, fix_int_precision(p$1, trans(iconv, 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, @@ -4347,7 +4348,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { if (typeof prec === "number") { if (prec !== 0) { return function (p, x) { - var str = fix_padding(padty$1, w, fix_int_precision(p, trans(iconv, 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, @@ -4357,7 +4358,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { } else { return function (x) { - var str = fix_padding(padty$1, w, trans(iconv, x)); + var str = fix_padding(padty$1, w, Caml_curry.app2(trans, iconv, x)); return make_printf(k, o, [ /* Acc_data_string */4, acc, @@ -4369,7 +4370,7 @@ function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { else { var p$2 = prec[1]; return function (x) { - var str = fix_padding(padty$1, w, fix_int_precision(p$2, trans(iconv, 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, @@ -4384,7 +4385,7 @@ function make_custom(k, o, acc, rest, arity, f) { if (arity) { var arity$1 = arity[1]; return function (x) { - return make_custom(k, o, acc, rest, arity$1, f(x)); + return make_custom(k, o, acc, rest, arity$1, Caml_curry.app1(f, x)); }; } else { @@ -4432,10 +4433,10 @@ function output_acc(o, _acc) { break; case 6 : output_acc(o, acc[1]); - return acc[2](o); + return Caml_curry.app1(acc[2], o); case 7 : output_acc(o, acc[1]); - return Pervasives.flush(o); + return Caml_curry.app1(Pervasives.flush, o); case 8 : output_acc(o, acc[1]); return Pervasives.invalid_arg(acc[2]); @@ -4448,7 +4449,7 @@ function output_acc(o, _acc) { return Pervasives.output_string(o, acc[2]); case 2 : output_acc(o, acc[1]); - return Pervasives.output_char(o, acc[2]); + return Caml_curry.app2(Pervasives.output_char, o, acc[2]); } }; @@ -4490,7 +4491,7 @@ function bufput_acc(b, _acc) { break; case 6 : bufput_acc(b, acc[1]); - return acc[2](b); + return Caml_curry.app1(acc[2], b); case 7 : _acc = acc[1]; break; @@ -4548,7 +4549,7 @@ function strput_acc(b, _acc) { break; case 6 : strput_acc(b, acc[1]); - return Buffer.add_string(b, acc[2](/* () */0)); + return Buffer.add_string(b, Caml_curry.app1(acc[2], /* () */0)); case 7 : _acc = acc[1]; break; @@ -4590,19 +4591,19 @@ function open_box_of_string(str) { else { var len = str.length; var invalid_box = function () { - return failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid box description ", + return Caml_curry.app1(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "invalid box description %S" - ])(str); + /* String_literal */11, + "invalid box description ", + [ + /* Caml_string */3, + /* No_padding */0, + /* End_of_format */0 + ] + ], + "invalid box description %S" + ]), str); }; var parse_spaces = function (_i) { while(true) { @@ -4823,117 +4824,117 @@ function make_padprec_fmt_ebb(pad, prec, fmt) { function fmt_ebb_of_string(legacy_behavior, str) { var legacy_behavior$1 = legacy_behavior ? legacy_behavior[1] : /* true */1; var invalid_format_message = function (str_ind, msg) { - return failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + return Caml_curry.app3(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": at character number ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": at character number ", [ - /* String_literal */11, - ", ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* String */2, - /* No_padding */0, - /* End_of_format */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); + ], + "invalid format %S: at character number %d, %s" + ]), str, str_ind, msg); }; var invalid_format_without = function (str_ind, c, s) { - return failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + return Caml_curry.app4(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": at character number ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": at character number ", [ - /* String_literal */11, - ", '", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Char */0, + /* String_literal */11, + ", '", [ - /* String_literal */11, - "' without ", + /* Char */0, [ - /* String */2, - /* No_padding */0, - /* End_of_format */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); + ], + "invalid format %S: at character number %d, '%c' without %s" + ]), str, str_ind, c, s); }; var expected_character = function (str_ind, expected, read) { - return failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + return Caml_curry.app4(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": at character number ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": at character number ", [ - /* String_literal */11, - ", ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ", ", [ - /* String_literal */11, - " expected, read ", + /* String */2, + /* No_padding */0, [ - /* Caml_char */1, - /* End_of_format */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); + ], + "invalid format %S: at character number %d, %s expected, read %C" + ]), str, str_ind, expected, read); }; var parse_literal = function (lit_start, _str_ind, end_ind) { while(true) { @@ -4997,36 +4998,36 @@ function fmt_ebb_of_string(legacy_behavior, str) { ]; var set_flag = function (str_ind, flag) { if (flag[1] && !legacy_behavior$1) { - failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + Caml_curry.app3(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": at character number ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": at character number ", [ - /* String_literal */11, - ", duplicate flag ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Caml_char */1, - /* End_of_format */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)); + ], + "invalid format %S: at character number %d, duplicate flag %C" + ]), str, str_ind, str.charCodeAt(str_ind)); } flag[1] = /* true */1; return /* () */0; @@ -6023,37 +6024,38 @@ function fmt_ebb_of_string(legacy_behavior, str) { ]; break; case 6 : - fmt_result = failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + fmt_result = Caml_curry.app3(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": at character number ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": at character number ", [ - /* String_literal */11, - ", flag ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Caml_char */1, + /* String_literal */11, + ", flag ", [ - /* String_literal */11, - " is only allowed after the '", + /* Caml_char */1, [ - /* Char_literal */12, - /* "%" */37, + /* String_literal */11, + " is only allowed after the '", [ - /* String_literal */11, - "', before padding and precision", - /* End_of_format */0 + /* Char_literal */12, + /* "%" */37, + [ + /* String_literal */11, + "', before padding and precision", + /* End_of_format */0 + ] ] ] ] @@ -6061,10 +6063,9 @@ function fmt_ebb_of_string(legacy_behavior, str) { ] ] ] - ] - ], - "invalid format %S: at character number %d, flag %C is only allowed after the '%%', before padding and precision" - ])(str, pct_ind, symb); + ], + "invalid format %S: at character number %d, flag %C is only allowed after the '%%', before padding and precision" + ]), str, pct_ind, symb); break; case 7 : if (symb >= 108) { @@ -6205,44 +6206,44 @@ function fmt_ebb_of_string(legacy_behavior, str) { } break; case 8 : - fmt_result = failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + fmt_result = Caml_curry.app3(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": at character number ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": at character number ", [ - /* String_literal */11, - ', invalid conversion "', + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Char_literal */12, - /* "%" */37, + /* String_literal */11, + ', invalid conversion "', [ - /* Char */0, + /* Char_literal */12, + /* "%" */37, [ - /* Char_literal */12, - /* "\"" */34, - /* End_of_format */0 + /* 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); + ], + 'invalid format %S: at character number %d, invalid conversion "%%%c"' + ]), str, str_ind - 1, symb); break; } @@ -6843,41 +6844,42 @@ function fmt_ebb_of_string(legacy_behavior, str) { return /* () */0; }; var fail_single_percent = function (str_ind) { - return failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + return Caml_curry.app2(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": '", + /* Caml_string */3, + /* No_padding */0, [ - /* Char_literal */12, - /* "%" */37, + /* String_literal */11, + ": '", [ - /* String_literal */11, - "' alone is not accepted in character sets, use ", + /* Char_literal */12, + /* "%" */37, [ - /* Char_literal */12, - /* "%" */37, + /* String_literal */11, + "' alone is not accepted in character sets, use ", [ /* Char_literal */12, /* "%" */37, [ - /* String_literal */11, - " instead at position ", + /* Char_literal */12, + /* "%" */37, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + " instead at position ", [ - /* Char_literal */12, - /* "." */46, - /* End_of_format */0 + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, + [ + /* Char_literal */12, + /* "." */46, + /* End_of_format */0 + ] ] ] ] @@ -6886,10 +6888,9 @@ function fmt_ebb_of_string(legacy_behavior, str) { ] ] ] - ] - ], - "invalid format %S: '%%' alone is not accepted in character sets, use %%%% instead at position %d." - ])(str, str_ind); + ], + "invalid format %S: '%%' alone is not accepted in character sets, use %%%% instead at position %d." + ]), str, str_ind); }; var parse_char_set_start = function (str_ind, end_ind) { if (str_ind === end_ind) { @@ -7068,39 +7069,39 @@ 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 failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + return Caml_curry.app3(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": integer ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": integer ", [ - /* String_literal */11, - " is greater than the limit ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */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); + ], + "invalid format %S: integer %d is greater than the limit %d" + ]), str, new_acc, Sys.max_string_length); } else { _acc = new_acc; @@ -7196,40 +7197,40 @@ function fmt_ebb_of_string(legacy_behavior, str) { while(true) { var str_ind = _str_ind; if (str_ind === end_ind) { - failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + Caml_curry.app3(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ': unclosed sub-format, expected "', + /* Caml_string */3, + /* No_padding */0, [ - /* Char_literal */12, - /* "%" */37, + /* String_literal */11, + ': unclosed sub-format, expected "', [ - /* Char */0, + /* Char_literal */12, + /* "%" */37, [ - /* String_literal */11, - '" at character number ', + /* Char */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */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); + ], + 'invalid format %S: unclosed sub-format, expected "%%%c" at character number %d' + ]), str, c, end_ind); } var match = str.charCodeAt(str_ind); if (match !== 37) { @@ -7780,40 +7781,41 @@ 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 failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "invalid format ", + return Caml_curry.app5(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "invalid format ", [ - /* String_literal */11, - ": at character number ", + /* Caml_string */3, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ": at character number ", [ - /* String_literal */11, - ", ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ", ", [ - /* String_literal */11, - " is incompatible with '", + /* String */2, + /* No_padding */0, [ - /* Char */0, + /* String_literal */11, + " is incompatible with '", [ - /* String_literal */11, - "' in sub-format ", + /* Char */0, [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 + /* String_literal */11, + "' in sub-format ", + [ + /* Caml_string */3, + /* No_padding */0, + /* End_of_format */0 + ] ] ] ] @@ -7822,10 +7824,9 @@ function fmt_ebb_of_string(legacy_behavior, str) { ] ] ] - ] - ], - "invalid format %S: at character number %d, %s is incompatible with '%c' in sub-format %S" - ])(str, pct_ind, option, symb, subfmt); + ], + "invalid format %S: at character number %d, %s is incompatible with '%c' in sub-format %S" + ]), str, pct_ind, option, symb, subfmt); }; return parse_literal(0, 0, str.length); } @@ -7841,27 +7842,27 @@ function format_of_string_fmtty(str, fmtty) { } catch (exn){ if (exn === Type_mismatch) { - return failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "bad input: format type mismatch between ", + return Caml_curry.app2(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "bad input: format type mismatch between ", [ - /* String_literal */11, - " and ", + /* Caml_string */3, + /* No_padding */0, [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */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)); + ], + "bad input: format type mismatch between %S and %S" + ]), str, string_of_fmtty(fmtty)); } else { throw exn; @@ -7880,27 +7881,27 @@ function format_of_string_format(str, param) { } catch (exn){ if (exn === Type_mismatch) { - return failwith_message([ - /* Format */0, - [ - /* String_literal */11, - "bad input: format type mismatch between ", + return Caml_curry.app2(failwith_message([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "bad input: format type mismatch between ", [ - /* String_literal */11, - " and ", + /* Caml_string */3, + /* No_padding */0, [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */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]); + ], + "bad input: format type mismatch between %S and %S" + ]), str, param[2]); } else { throw exn; diff --git a/jscomp/stdlib/camlinternalLazy.js b/jscomp/stdlib/camlinternalLazy.js index 5bb1fe8337..693042ca00 100644 --- a/jscomp/stdlib/camlinternalLazy.js +++ b/jscomp/stdlib/camlinternalLazy.js @@ -4,6 +4,7 @@ var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var Obj = require("./obj"); var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); var Undefined = [ 248, @@ -19,7 +20,7 @@ function force_lazy_block(blk) { var closure = blk[0]; blk[0] = raise_undefined; try { - var result = closure(/* () */0); + var result = Caml_curry.app1(closure, /* () */0); blk[0] = result; Caml_obj_runtime.caml_obj_set_tag(blk, Obj.forward_tag); return result; @@ -35,7 +36,7 @@ function force_lazy_block(blk) { function force_val_lazy_block(blk) { var closure = blk[0]; blk[0] = raise_undefined; - var result = closure(/* () */0); + var result = Caml_curry.app1(closure, /* () */0); blk[0] = result; Caml_obj_runtime.caml_obj_set_tag(blk, Obj.forward_tag); return result; diff --git a/jscomp/stdlib/camlinternalMod.js b/jscomp/stdlib/camlinternalMod.js index 396e33f5ce..87f69ef1ef 100644 --- a/jscomp/stdlib/camlinternalMod.js +++ b/jscomp/stdlib/camlinternalMod.js @@ -6,6 +6,7 @@ var Obj = require("./obj"); var Caml_exceptions = require("../runtime/caml_exceptions"); var CamlinternalOO = require("./camlinternalOO"); var $$Array = require("./array"); +var Caml_curry = require("../runtime/caml_curry"); function init_mod(loc, shape) { if (typeof shape === "number") { @@ -73,7 +74,7 @@ function update_mod(shape, o, n) { } else { return overwrite(o, function (x) { - return n(x); + return Caml_curry.app1(n, x); }); } case 1 : diff --git a/jscomp/stdlib/camlinternalOO.js b/jscomp/stdlib/camlinternalOO.js index 726c093f7c..f73b83f4d2 100644 --- a/jscomp/stdlib/camlinternalOO.js +++ b/jscomp/stdlib/camlinternalOO.js @@ -10,6 +10,7 @@ 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"); var Caml_string = require("../runtime/caml_string"); var List = require("./list"); @@ -178,7 +179,7 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; } else { @@ -813,9 +814,9 @@ function init_class(table) { function inherits(cla, vals, virt_meths, concr_meths, param, top) { var $$super = param[2]; narrow(cla, vals, virt_meths, concr_meths); - var init = top ? $$super(cla, param[4]) : $$super(cla); + var init = top ? Caml_curry.app2($$super, cla, param[4]) : Caml_curry.app1($$super, cla); widen(cla); - return $$Array.concat([ + return Caml_curry.app1($$Array.concat, [ /* :: */0, /* array */[init], [ @@ -836,11 +837,11 @@ function inherits(cla, vals, virt_meths, concr_meths, param, top) { function make_class(pub_meths, class_init) { var table = create_table(pub_meths); - var env_init = class_init(table); + var env_init = Caml_curry.app1(class_init, table); init_class(table); return [ /* tuple */0, - env_init(0), + Caml_curry.app1(env_init, 0), class_init, env_init, 0 @@ -849,7 +850,7 @@ function make_class(pub_meths, class_init) { function make_class_store(pub_meths, class_init, init_table) { var table = create_table(pub_meths); - var env_init = class_init(table); + var env_init = Caml_curry.app1(class_init, table); init_class(table); init_table[2] = class_init; init_table[1] = env_init; @@ -894,7 +895,7 @@ function iter_f(obj, _param) { while(true) { var param = _param; if (param) { - param[1](obj); + Caml_curry.app1(param[1], obj); _param = param[2]; } else { @@ -1031,7 +1032,7 @@ function method_impl(table, i, arr) { case 3 : var n$3 = next(/* () */0); return function (obj) { - return obj[1][n$3](obj); + return Caml_curry.app1(obj[1][n$3], obj); }; case 4 : var n$4 = next(/* () */0); @@ -1043,13 +1044,13 @@ function method_impl(table, i, arr) { var f = next(/* () */0); var x$1 = next(/* () */0); return function () { - return f(x$1); + return Caml_curry.app1(f, x$1); }; case 6 : var f$1 = next(/* () */0); var n$5 = next(/* () */0); return function (obj) { - return f$1(obj[n$5]); + return Caml_curry.app1(f$1, obj[n$5]); }; case 7 : var f$2 = next(/* () */0); @@ -1059,7 +1060,7 @@ function method_impl(table, i, arr) { var e$3 = e$2; var n$7 = n$6; return function (obj) { - return f$3(obj[e$3][n$7]); + return Caml_curry.app1(f$3, obj[e$3][n$7]); }; case 8 : var f$4 = next(/* () */0); @@ -1067,14 +1068,14 @@ function method_impl(table, i, arr) { var f$5 = f$4; var n$9 = n$8; return function (obj) { - return f$5(obj[1][n$9](obj)); + return Caml_curry.app1(f$5, Caml_curry.app1(obj[1][n$9], obj)); }; case 9 : var f$6 = next(/* () */0); var x$2 = next(/* () */0); var y = next(/* () */0); return function () { - return f$6(x$2, y); + return Caml_curry.app2(f$6, x$2, y); }; case 10 : var f$7 = next(/* () */0); @@ -1084,7 +1085,7 @@ function method_impl(table, i, arr) { var x$4 = x$3; var n$11 = n$10; return function (obj) { - return f$8(x$4, obj[n$11]); + return Caml_curry.app2(f$8, x$4, obj[n$11]); }; case 11 : var f$9 = next(/* () */0); @@ -1096,7 +1097,7 @@ function method_impl(table, i, arr) { var e$5 = e$4; var n$13 = n$12; return function (obj) { - return f$10(x$6, obj[e$5][n$13]); + return Caml_curry.app2(f$10, x$6, obj[e$5][n$13]); }; case 12 : var f$11 = next(/* () */0); @@ -1106,7 +1107,7 @@ function method_impl(table, i, arr) { var x$8 = x$7; var n$15 = n$14; return function (obj) { - return f$12(x$8, obj[1][n$15](obj)); + return Caml_curry.app2(f$12, x$8, Caml_curry.app1(obj[1][n$15], obj)); }; case 13 : var f$13 = next(/* () */0); @@ -1116,7 +1117,7 @@ function method_impl(table, i, arr) { var n$17 = n$16; var x$10 = x$9; return function (obj) { - return f$14(obj[n$17], x$10); + return Caml_curry.app2(f$14, obj[n$17], x$10); }; case 14 : var f$15 = next(/* () */0); @@ -1128,7 +1129,7 @@ function method_impl(table, i, arr) { var n$19 = n$18; var x$12 = x$11; return function (obj) { - return f$16(obj[e$7][n$19], x$12); + return Caml_curry.app2(f$16, obj[e$7][n$19], x$12); }; case 15 : var f$17 = next(/* () */0); @@ -1138,7 +1139,7 @@ function method_impl(table, i, arr) { var n$21 = n$20; var x$14 = x$13; return function (obj) { - return f$18(obj[1][n$21](obj), x$14); + return Caml_curry.app2(f$18, Caml_curry.app1(obj[1][n$21], obj), x$14); }; case 16 : var n$22 = next(/* () */0); @@ -1146,7 +1147,7 @@ function method_impl(table, i, arr) { var n$23 = n$22; var x$16 = x$15; return function (obj) { - return obj[1][n$23](obj, x$16); + return Caml_curry.app2(obj[1][n$23], obj, x$16); }; case 17 : var n$24 = next(/* () */0); @@ -1154,7 +1155,7 @@ function method_impl(table, i, arr) { var n$25 = n$24; var m$1 = m; return function (obj) { - return obj[1][n$25](obj, obj[m$1]); + return Caml_curry.app2(obj[1][n$25], obj, obj[m$1]); }; case 18 : var n$26 = next(/* () */0); @@ -1164,7 +1165,7 @@ function method_impl(table, i, arr) { var e$9 = e$8; var m$3 = m$2; return function (obj) { - return obj[1][n$27](obj, obj[e$9][m$3]); + return Caml_curry.app2(obj[1][n$27], obj, obj[e$9][m$3]); }; case 19 : var n$28 = next(/* () */0); @@ -1172,7 +1173,7 @@ function method_impl(table, i, arr) { var n$29 = n$28; var m$5 = m$4; return function (obj) { - return obj[1][n$29](obj, obj[1][m$5](obj)); + return Caml_curry.app2(obj[1][n$29], obj, Caml_curry.app1(obj[1][m$5], obj)); }; case 20 : var m$6 = next(/* () */0); @@ -1181,7 +1182,7 @@ function method_impl(table, i, arr) { var x$18 = x$17; new_cache(table); return function () { - return Caml_oo.caml_get_public_method(x$18, m$7, 1)(x$18); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, x$18, m$7, 1), x$18); }; case 21 : var m$8 = next(/* () */0); @@ -1190,7 +1191,7 @@ function method_impl(table, i, arr) { var n$31 = n$30; new_cache(table); return function (obj) { - return Caml_oo.caml_get_public_method(obj[n$31], m$9, 2)(obj[n$31]); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, obj[n$31], m$9, 2), obj[n$31]); }; case 22 : var m$10 = next(/* () */0); @@ -1201,7 +1202,7 @@ function method_impl(table, i, arr) { var n$33 = n$32; new_cache(table); return function (obj) { - return Caml_oo.caml_get_public_method(obj[e$11][n$33], m$11, 3)(obj[e$11][n$33]); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, obj[e$11][n$33], m$11, 3), obj[e$11][n$33]); }; case 23 : var m$12 = next(/* () */0); @@ -1210,7 +1211,7 @@ function method_impl(table, i, arr) { var n$35 = n$34; new_cache(table); return function (obj) { - return Caml_oo.caml_get_public_method(obj[1][n$35](obj), m$13, 4)(obj[1][n$35](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)); }; } diff --git a/jscomp/stdlib/digest.js b/jscomp/stdlib/digest.js index ec4a9633f8..fbe0b9b2ae 100644 --- a/jscomp/stdlib/digest.js +++ b/jscomp/stdlib/digest.js @@ -6,6 +6,7 @@ var Pervasives = require("./pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Char = require("./char"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); var $$String = require("./string"); function string(str) { @@ -13,7 +14,7 @@ function string(str) { } function bytes(b) { - return string(Bytes.unsafe_to_string(b)); + return string(Caml_curry.app1(Bytes.unsafe_to_string, b)); } function substring(str, ofs, len) { @@ -26,7 +27,7 @@ function substring(str, ofs, len) { } function subbytes(b, ofs, len) { - return substring(Bytes.unsafe_to_string(b), ofs, len); + return substring(Caml_curry.app1(Bytes.unsafe_to_string, b), ofs, len); } function file(filename) { @@ -38,11 +39,11 @@ function file(filename) { exit = 1; } catch (e){ - Pervasives.close_in(ic); + Caml_curry.app1(Pervasives.close_in, ic); throw e; } if (exit === 1) { - Pervasives.close_in(ic); + Caml_curry.app1(Pervasives.close_in, ic); return d; } @@ -69,7 +70,7 @@ function to_hex(d) { result[i * 2] = char_hex((x >>> 4)); result[i * 2 + 1] = char_hex(x & 15); } - return Bytes.unsafe_to_string(result); + return Caml_curry.app1(Bytes.unsafe_to_string, result); } function from_hex(s) { @@ -123,7 +124,7 @@ function from_hex(s) { for(var i = 0; i<= 15; ++i){ result[i] = Char.chr($$byte(2 * i)); } - return Bytes.unsafe_to_string(result); + return Caml_curry.app1(Bytes.unsafe_to_string, result); } var compare = $$String.compare; diff --git a/jscomp/stdlib/filename.js b/jscomp/stdlib/filename.js index de54571899..b5cbe7d310 100644 --- a/jscomp/stdlib/filename.js +++ b/jscomp/stdlib/filename.js @@ -10,6 +10,7 @@ var Printf = require("./printf"); var Caml_primitive = require("../runtime/caml_primitive"); var Buffer = require("./buffer"); var $$String = require("./string"); +var Caml_curry = require("../runtime/caml_curry"); var Random = require("./random"); function generic_basename(is_dir_sep, current_dir_name, name) { @@ -23,7 +24,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - else if (is_dir_sep(name, n)) { + else if (Caml_curry.app2(is_dir_sep, name, n)) { _n = n - 1; } else { @@ -34,7 +35,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n$1 < 0) { return $$String.sub(name, 0, p); } - else if (is_dir_sep(name, n$1)) { + else if (Caml_curry.app2(is_dir_sep, name, n$1)) { return $$String.sub(name, n$1 + 1, p - n$1 - 1); } else { @@ -57,7 +58,7 @@ function generic_dirname(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - else if (is_dir_sep(name, n)) { + else if (Caml_curry.app2(is_dir_sep, name, n)) { _n = n - 1; } else { @@ -67,14 +68,14 @@ function generic_dirname(is_dir_sep, current_dir_name, name) { if (n$1 < 0) { return current_dir_name; } - else if (is_dir_sep(name, n$1)) { + else if (Caml_curry.app2(is_dir_sep, name, n$1)) { var _n$2 = n$1; while(true) { var n$2 = _n$2; if (n$2 < 0) { return $$String.sub(name, 0, 1); } - else if (is_dir_sep(name, n$2)) { + else if (Caml_curry.app2(is_dir_sep, name, n$2)) { _n$2 = n$2 - 1; } else { @@ -191,7 +192,7 @@ var dir_sep = "/"; function concat(dirname, filename) { var l = dirname.length; - if (l === 0 || is_dir_sep$1(dirname, l - 1)) { + if (l === 0 || Caml_curry.app2(is_dir_sep$1, dirname, l - 1)) { return dirname + filename; } else { @@ -213,7 +214,7 @@ function chop_extension(name) { var _i = name.length - 1; while(true) { var i = _i; - if (i < 0 || is_dir_sep$1(name, i)) { + if (i < 0 || Caml_curry.app2(is_dir_sep$1, name, i)) { return Pervasives.invalid_arg("Filename.chop_extension"); } else if (name[i] === ".") { @@ -228,38 +229,38 @@ function chop_extension(name) { var prng = [ 246, function () { - return Random.State[2](/* () */0); + return Caml_curry.app1(Random.State[2], /* () */0); } ]; function temp_file_name(temp_dir, prefix, suffix) { var tag = Caml_obj_runtime.caml_obj_tag(prng); - var rnd = Random.State[4](tag === 250 ? prng[1] : ( + var rnd = Caml_curry.app1(Random.State[4], tag === 250 ? prng[1] : ( tag === 246 ? CamlinternalLazy.force_lazy_block(prng) : prng )) & 16777215; - return concat(temp_dir, Printf.sprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + return concat(temp_dir, Caml_curry.app3(Printf.sprintf([ + /* Format */0, [ - /* Int */4, - /* Int_x */6, - [ - /* Lit_padding */0, - /* Zeros */2, - 6 - ], - /* No_precision */0, + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, - /* End_of_format */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)); + ], + "%s%06x%s" + ]), prefix, rnd, suffix)); } var current_temp_dir_name = [ diff --git a/jscomp/stdlib/format.js b/jscomp/stdlib/format.js index 7471f3fc70..5cc66b31a9 100644 --- a/jscomp/stdlib/format.js +++ b/jscomp/stdlib/format.js @@ -5,6 +5,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); 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"); @@ -81,22 +82,22 @@ function pp_clear_queue(state) { var pp_infinity = 1000000010; function pp_output_string(state, s) { - return state[17](s, 0, s.length); + return Caml_curry.app3(state[17], s, 0, s.length); } function break_new_line(state, offset, width) { - state[19](/* () */0); + 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 state[20](state[10]); + return Caml_curry.app1(state[20], state[10]); } function break_same_line(state, width) { state[9] -= width; - return state[20](width); + return Caml_curry.app1(state[20], width); } function pp_force_break_line(state) { @@ -113,7 +114,7 @@ function pp_force_break_line(state) { } } else { - return state[19](/* () */0); + return Caml_curry.app1(state[19], /* () */0); } } @@ -181,7 +182,7 @@ function format_pp_token(state, size, param) { return break_new_line(state, 0, match$3[1][2]); } else { - return state[19](/* () */0); + return Caml_curry.app1(state[19], /* () */0); } case 4 : if (state[10] !== state[6] - state[9]) { @@ -198,7 +199,7 @@ function format_pp_token(state, size, param) { case 5 : var match$5 = state[5]; if (match$5) { - var marker = state[24](match$5[1]); + var marker = Caml_curry.app1(state[24], match$5[1]); pp_output_string(state, marker); state[5] = match$5[2]; return /* () */0; @@ -333,7 +334,7 @@ function format_pp_token(state, size, param) { return /* () */0; case 5 : var tag_name = param[1]; - var marker$1 = state[23](tag_name); + var marker$1 = Caml_curry.app1(state[23], tag_name); pp_output_string(state, marker$1); state[5] = [ /* :: */0, @@ -535,7 +536,7 @@ function pp_open_tag(state, tag_name) { tag_name, state[4] ]; - state[25](tag_name); + Caml_curry.app1(state[25], tag_name); } if (state[22]) { return pp_enqueue(state, [ @@ -565,7 +566,7 @@ function pp_close_tag(state, _) { if (state[21]) { var match = state[4]; if (match) { - state[26](match[1]); + Caml_curry.app1(state[26], match[1]); state[4] = match[2]; return /* () */0; } @@ -640,7 +641,7 @@ function pp_flush_queue(state, b) { state[13] = pp_infinity; advance_left(state); if (b) { - state[19](/* () */0); + Caml_curry.app1(state[19], /* () */0); } return pp_rinit(state); } @@ -700,12 +701,12 @@ function pp_open_box(state, indent) { function pp_print_newline(state, _) { pp_flush_queue(state, /* true */1); - return state[18](/* () */0); + return Caml_curry.app1(state[18], /* () */0); } function pp_print_flush(state, _) { pp_flush_queue(state, /* false */0); - return state[18](/* () */0); + return Caml_curry.app1(state[18], /* () */0); } function pp_force_newline(state, _) { @@ -857,8 +858,8 @@ function pp_print_list(_$staropt$star, pp_v, ppf, _param) { var vs = param[2]; var v = param[1]; if (vs) { - pp_v(ppf, v); - pp_sep(ppf, /* () */0); + Caml_curry.app2(pp_v, ppf, v); + Caml_curry.app2(pp_sep, ppf, /* () */0); _param = vs; _$staropt$star = [ /* Some */0, @@ -866,7 +867,7 @@ function pp_print_list(_$staropt$star, pp_v, ppf, _param) { ]; } else { - return pp_v(ppf, v); + return Caml_curry.app2(pp_v, ppf, v); } } else { @@ -1035,7 +1036,7 @@ function pp_get_all_formatter_output_functions(state, _) { } function display_newline(state, _) { - return state[17]("\n", 0, 1); + return Caml_curry.app3(state[17], "\n", 0, 1); } var blank_line = $$String.make(80, /* " " */32); @@ -1045,10 +1046,10 @@ function display_blanks(state, _n) { var n = _n; if (n > 0) { if (n <= 80) { - return state[17](blank_line, 0, n); + return Caml_curry.app3(state[17], blank_line, 0, n); } else { - state[17](blank_line, 0, 80); + Caml_curry.app3(state[17], blank_line, 0, 80); _n = n - 80; } } @@ -1063,7 +1064,7 @@ function pp_set_formatter_out_channel(state, os) { return Pervasives.output_substring(os, param, param$1, param$2); }; state[18] = function () { - return Pervasives.flush(os); + return Caml_curry.app1(Pervasives.flush, os); }; state[19] = function (param) { return display_newline(state, param); @@ -1168,7 +1169,7 @@ function formatter_of_out_channel(oc) { return make_formatter(function (param, param$1, param$2) { return Pervasives.output_substring(oc, param, param$1, param$2); }, function () { - return Pervasives.flush(oc); + return Caml_curry.app1(Pervasives.flush, oc); }); } @@ -1404,7 +1405,7 @@ function set_tags(param) { function compute_tag(output, tag_acc) { var buf = Buffer.create(16); var ppf = formatter_of_buffer(buf); - output(ppf, tag_acc); + Caml_curry.app2(output, ppf, tag_acc); pp_print_flush(ppf, /* () */0); var len = Buffer.length(buf); if (len < 2) { @@ -1595,7 +1596,7 @@ function output_acc(ppf, acc) { break; case 6 : output_acc(ppf, acc[1]); - return acc[2](ppf); + return Caml_curry.app1(acc[2], ppf); case 7 : output_acc(ppf, acc[1]); return pp_print_flush(ppf, /* () */0); @@ -1776,7 +1777,7 @@ function strput_acc(ppf, acc) { } else if (match$6[0] === 1) { strput_acc(ppf, p$7[1]); - return pp_print_as_size(ppf, match$6[2], acc[2](/* () */0)); + return pp_print_as_size(ppf, match$6[2], Caml_curry.app1(acc[2], /* () */0)); } else { exit$5 = 3; @@ -1784,7 +1785,7 @@ function strput_acc(ppf, acc) { } if (exit$5 === 3) { strput_acc(ppf, p$7); - return pp_print_string(ppf, acc[2](/* () */0)); + return pp_print_string(ppf, Caml_curry.app1(acc[2], /* () */0)); } break; case 7 : @@ -1810,13 +1811,13 @@ function strput_acc(ppf, acc) { function kfprintf(k, o, param) { return CamlinternalFormat.make_printf(function (o, acc) { output_acc(o, acc); - return k(o); + return Caml_curry.app1(k, o); }, o, /* End_of_acc */0, param[1]); } function ikfprintf(k, x, param) { return CamlinternalFormat.make_printf(function (_, _$1) { - return k(x); + return Caml_curry.app1(k, x); }, x, /* End_of_acc */0, param[1]); } @@ -1845,7 +1846,7 @@ function ksprintf(k, param) { var ppf = formatter_of_buffer(b); var k$prime = function (_, acc) { strput_acc(ppf, acc); - return k(flush_buf_formatter(b, ppf)); + return Caml_curry.app1(k, flush_buf_formatter(b, ppf)); }; return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[1]); } diff --git a/jscomp/stdlib/gc.js b/jscomp/stdlib/gc.js index 40b5402937..4cac67a231 100644 --- a/jscomp/stdlib/gc.js +++ b/jscomp/stdlib/gc.js @@ -1,304 +1,305 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Sys = require("./sys"); -var Printf = require("./printf"); +var Sys = require("./sys"); +var Printf = require("./printf"); +var Caml_curry = require("../runtime/caml_curry"); function print_stat(c) { - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "minor_words: ", + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Float */8, - /* Float_f */0, - /* No_padding */0, + /* String_literal */11, + "minor_words: ", [ - /* Lit_precision */0, - 0 - ], - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "promoted_words: ", + ], + "minor_words: %.0f\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Float */8, - /* Float_f */0, - /* No_padding */0, + /* String_literal */11, + "promoted_words: ", [ - /* Lit_precision */0, - 0 - ], - [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "major_words: ", + ], + "promoted_words: %.0f\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Float */8, - /* Float_f */0, - /* No_padding */0, - [ - /* Lit_precision */0, - 0 - ], + /* String_literal */11, + "major_words: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "minor_collections: ", + ], + "major_words: %.0f\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "minor_collections: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "major_collections: ", + ], + "minor_collections: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "major_collections: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "heap_words: ", + ], + "major_collections: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "heap_words: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "heap_chunks: ", + ], + "heap_words: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "heap_chunks: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "top_heap_words: ", + ], + "heap_chunks: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "top_heap_words: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "live_words: ", + ], + "top_heap_words: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "live_words: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "live_blocks: ", + ], + "live_words: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "live_blocks: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "free_words: ", + ], + "live_blocks: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "free_words: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "free_blocks: ", + ], + "free_words: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "free_blocks: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "largest_free: ", + ], + "free_blocks: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "largest_free: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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); - Printf.fprintf(c, [ - /* Format */0, - [ - /* String_literal */11, - "fragments: ", + ], + "largest_free: %d\n" + ]), 0); + Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "fragments: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ] - ], - "fragments: %d\n" - ])(0); - return Printf.fprintf(c, [ - /* Format */0, + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* String_literal */11, - "compactions: ", + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] + ] + ], + "fragments: %d\n" + ]), 0); + return Caml_curry.app1(Printf.fprintf(c, [ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "compactions: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] ] - ] - ], - "compactions: %d\n" - ])(0); + ], + "compactions: %d\n" + ]), 0); } function allocated_bytes() { diff --git a/jscomp/stdlib/hashtbl.js b/jscomp/stdlib/hashtbl.js index b2c8f51538..18cd890e6e 100644 --- a/jscomp/stdlib/hashtbl.js +++ b/jscomp/stdlib/hashtbl.js @@ -11,6 +11,7 @@ var Caml_primitive = require("../runtime/caml_primitive"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("./array"); var $$String = require("./string"); +var Caml_curry = require("../runtime/caml_curry"); var Random = require("./random"); function hash(x) { @@ -64,7 +65,7 @@ function randomize() { var prng = [ 246, function () { - return Random.State[2](/* () */0); + return Caml_curry.app1(Random.State[2], /* () */0); } ]; @@ -89,7 +90,7 @@ function create($staropt$star, initial_size) { var seed; if (random) { var tag = Caml_obj_runtime.caml_obj_tag(prng); - seed = Random.State[4](tag === 250 ? prng[1] : ( + seed = Caml_curry.app1(Random.State[4], tag === 250 ? prng[1] : ( tag === 246 ? CamlinternalLazy.force_lazy_block(prng) : prng )); } @@ -151,7 +152,7 @@ function resize(indexfun, h) { if (param) { var key = param[1]; insert_bucket(param[3]); - var nidx = indexfun(h, key); + var nidx = Caml_curry.app2(indexfun, h, key); ndata[nidx] = [ /* Cons */0, key, @@ -383,7 +384,7 @@ function iter(f, h) { while(true) { var param = _param; if (param) { - f(param[1], param[2]); + Caml_curry.app2(f, param[1], param[2]); _param = param[3]; } else { @@ -404,7 +405,7 @@ function fold(f, h, init) { var accu = _accu; var b = _b; if (b) { - _accu = f(b[1], b[2], accu); + _accu = Caml_curry.app3(f, b[1], b[2], accu); _b = b[3]; } else { @@ -455,7 +456,7 @@ function stats(h) { function MakeSeeded(H) { var key_index = function (h, key) { - return H[2](h[3], key) & h[2].length - 1; + return Caml_curry.app2(H[2], h[3], key) & h[2].length - 1; }; var add = function (h, key, info) { var i = key_index(h, key); @@ -480,7 +481,7 @@ function MakeSeeded(H) { if (param) { var next = param[3]; var k = param[1]; - if (H[1](k, key)) { + if (Caml_curry.app2(H[1], k, key)) { -- h[1]; return next; } @@ -505,16 +506,16 @@ function MakeSeeded(H) { var match = h[2][key_index(h, key)]; if (match) { var rest1 = match[3]; - if (H[1](key, match[1])) { + if (Caml_curry.app2(H[1], key, match[1])) { return match[2]; } else if (rest1) { var rest2 = rest1[3]; - if (H[1](key, rest1[1])) { + if (Caml_curry.app2(H[1], key, rest1[1])) { return rest1[2]; } else if (rest2) { - if (H[1](key, rest2[1])) { + if (Caml_curry.app2(H[1], key, rest2[1])) { return rest2[2]; } else { @@ -523,7 +524,7 @@ function MakeSeeded(H) { while(true) { var param = _param; if (param) { - if (H[1](key$1, param[1])) { + if (Caml_curry.app2(H[1], key$1, param[1])) { return param[2]; } else { @@ -554,7 +555,7 @@ function MakeSeeded(H) { var param = _param; if (param) { var rest = param[3]; - if (H[1](param[1], key)) { + if (Caml_curry.app2(H[1], param[1], key)) { return [ /* :: */0, param[2], @@ -577,7 +578,7 @@ function MakeSeeded(H) { if (param) { var next = param[3]; var k = param[1]; - if (H[1](k, key)) { + if (Caml_curry.app2(H[1], k, key)) { return [ /* Cons */0, key, @@ -630,7 +631,7 @@ function MakeSeeded(H) { while(true) { var param = _param; if (param) { - if (H[1](param[1], key)) { + if (Caml_curry.app2(H[1], param[1], key)) { return /* true */1; } else { @@ -664,7 +665,7 @@ function MakeSeeded(H) { function Make(H) { var equal = H[1]; var key_index = function (h, key) { - return H[2](key) & h[2].length - 1; + return Caml_curry.app1(H[2], key) & h[2].length - 1; }; var add = function (h, key, info) { var i = key_index(h, key); @@ -689,7 +690,7 @@ function Make(H) { if (param) { var next = param[3]; var k = param[1]; - if (equal(k, key)) { + if (Caml_curry.app2(equal, k, key)) { -- h[1]; return next; } @@ -714,16 +715,16 @@ function Make(H) { var match = h[2][key_index(h, key)]; if (match) { var rest1 = match[3]; - if (equal(key, match[1])) { + if (Caml_curry.app2(equal, key, match[1])) { return match[2]; } else if (rest1) { var rest2 = rest1[3]; - if (equal(key, rest1[1])) { + if (Caml_curry.app2(equal, key, rest1[1])) { return rest1[2]; } else if (rest2) { - if (equal(key, rest2[1])) { + if (Caml_curry.app2(equal, key, rest2[1])) { return rest2[2]; } else { @@ -732,7 +733,7 @@ function Make(H) { while(true) { var param = _param; if (param) { - if (equal(key$1, param[1])) { + if (Caml_curry.app2(equal, key$1, param[1])) { return param[2]; } else { @@ -763,7 +764,7 @@ function Make(H) { var param = _param; if (param) { var rest = param[3]; - if (equal(param[1], key)) { + if (Caml_curry.app2(equal, param[1], key)) { return [ /* :: */0, param[2], @@ -786,7 +787,7 @@ function Make(H) { if (param) { var next = param[3]; var k = param[1]; - if (equal(k, key)) { + if (Caml_curry.app2(equal, k, key)) { return [ /* Cons */0, key, @@ -839,7 +840,7 @@ function Make(H) { while(true) { var param = _param; if (param) { - if (equal(param[1], key)) { + if (Caml_curry.app2(equal, param[1], key)) { return /* true */1; } else { diff --git a/jscomp/stdlib/lexing.js b/jscomp/stdlib/lexing.js index e7e3f1c9e5..9809b5228d 100644 --- a/jscomp/stdlib/lexing.js +++ b/jscomp/stdlib/lexing.js @@ -5,6 +5,7 @@ var Bytes = require("./bytes"); var Pervasives = require("./pervasives"); var Caml_lexer = require("../runtime/caml_lexer"); var Sys = require("./sys"); +var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); function engine(tbl, state, buf) { @@ -54,7 +55,7 @@ function from_function(f) { var read_fun = f; var aux_buffer = new Array(512); var lexbuf = param; - var read = read_fun(aux_buffer, aux_buffer.length); + 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) { diff --git a/jscomp/stdlib/list.js b/jscomp/stdlib/list.js index 4625c0a290..ef8ddda12e 100644 --- a/jscomp/stdlib/list.js +++ b/jscomp/stdlib/list.js @@ -4,6 +4,7 @@ var Pervasives = require("./pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); function length(l) { var _len = 0; @@ -98,7 +99,7 @@ function flatten(param) { function map(f, param) { if (param) { - var r = f(param[1]); + var r = Caml_curry.app1(f, param[1]); return [ /* :: */0, r, @@ -112,7 +113,7 @@ function map(f, param) { function mapi(i, f, param) { if (param) { - var r = f(i, param[1]); + var r = Caml_curry.app2(f, i, param[1]); return [ /* :: */0, r, @@ -138,7 +139,7 @@ function rev_map(f, l) { _param = param[2]; _accu = [ /* :: */0, - f(param[1]), + Caml_curry.app1(f, param[1]), accu ]; } @@ -152,7 +153,7 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - f(param[1]); + Caml_curry.app1(f, param[1]); _param = param[2]; } else { @@ -169,7 +170,7 @@ function iteri(f, l) { var param = _param; var i = _i; if (param) { - f$1(i, param[1]); + Caml_curry.app2(f$1, i, param[1]); _param = param[2]; _i = i + 1; } @@ -185,7 +186,7 @@ function fold_left(f, _accu, _l) { var accu = _accu; if (l) { _l = l[2]; - _accu = f(accu, l[1]); + _accu = Caml_curry.app2(f, accu, l[1]); } else { return accu; @@ -195,7 +196,7 @@ function fold_left(f, _accu, _l) { function fold_right(f, l, accu) { if (l) { - return f(l[1], fold_right(f, l[2], accu)); + return Caml_curry.app2(f, l[1], fold_right(f, l[2], accu)); } else { return accu; @@ -205,7 +206,7 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - var r = f(l1[1], l2[1]); + var r = Caml_curry.app2(f, l1[1], l2[1]); return [ /* :: */0, r, @@ -238,7 +239,7 @@ function rev_map2(f, l1, l2) { _l1 = l1$1[2]; _accu = [ /* :: */0, - f(l1$1[1], l2$1[1]), + Caml_curry.app2(f, l1$1[1], l2$1[1]), accu ]; } @@ -261,7 +262,7 @@ function iter2(f, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - f(l1[1], l2[1]); + Caml_curry.app2(f, l1[1], l2[1]); _l2 = l2[2]; _l1 = l1[2]; } @@ -287,7 +288,7 @@ function fold_left2(f, _accu, _l1, _l2) { if (l2) { _l2 = l2[2]; _l1 = l1[2]; - _accu = f(accu, l1[1], l2[1]); + _accu = Caml_curry.app3(f, accu, l1[1], l2[1]); } else { return Pervasives.invalid_arg("List.fold_left2"); @@ -305,7 +306,7 @@ function fold_left2(f, _accu, _l1, _l2) { function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return f(l1[1], l2[1], fold_right2(f, l1[2], l2[2], accu)); + return Caml_curry.app3(f, l1[1], l2[1], fold_right2(f, l1[2], l2[2], accu)); } else { return Pervasives.invalid_arg("List.fold_right2"); @@ -323,7 +324,7 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[1])) { + if (Caml_curry.app1(p, param[1])) { _param = param[2]; } else { @@ -340,7 +341,7 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[1])) { + if (Caml_curry.app1(p, param[1])) { return /* true */1; } else { @@ -359,7 +360,7 @@ function for_all2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (p(l1[1], l2[1])) { + if (Caml_curry.app2(p, l1[1], l2[1])) { _l2 = l2[2]; _l1 = l1[2]; } @@ -386,7 +387,7 @@ function exists2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (p(l1[1], l2[1])) { + if (Caml_curry.app2(p, l1[1], l2[1])) { return /* true */1; } else { @@ -556,7 +557,7 @@ function find(p, _param) { var param = _param; if (param) { var x = param[1]; - if (p(x)) { + if (Caml_curry.app1(p, x)) { return x; } else { @@ -579,7 +580,7 @@ function find_all(p) { if (param$1) { var l = param$1[2]; var x = param$1[1]; - if (p(x)) { + if (Caml_curry.app1(p, x)) { _param = l; _accu = [ /* :: */0, @@ -609,7 +610,7 @@ function partition(p, l) { if (param) { var l$1 = param[2]; var x = param[1]; - if (p(x)) { + if (Caml_curry.app1(p, x)) { _param = l$1; _yes = [ /* :: */0, @@ -693,7 +694,7 @@ function merge(cmp, l1, l2) { if (l2) { var h2 = l2[1]; var h1 = l1[1]; - if (cmp(h1, h2) <= 0) { + if (Caml_curry.app2(cmp, h1, h2) <= 0) { return [ /* :: */0, h1, @@ -760,8 +761,8 @@ function stable_sort(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { + if (Caml_curry.app2(cmp, x1, x2) <= 0) { + if (Caml_curry.app2(cmp, x2, x3) <= 0) { return [ /* :: */0, x1, @@ -776,7 +777,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x1, x3) <= 0) { + else if (Caml_curry.app2(cmp, x1, x3) <= 0) { return [ /* :: */0, x1, @@ -807,7 +808,7 @@ function stable_sort(cmp, l) { ]; } } - else if (cmp(x1, x3) <= 0) { + else if (Caml_curry.app2(cmp, x1, x3) <= 0) { return [ /* :: */0, x2, @@ -822,7 +823,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x2, x3) <= 0) { + else if (Caml_curry.app2(cmp, x2, x3) <= 0) { return [ /* :: */0, x2, @@ -870,7 +871,7 @@ function stable_sort(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - if (cmp(x1$1, x2$1) <= 0) { + if (Caml_curry.app2(cmp, x1$1, x2$1) <= 0) { return [ /* :: */0, x1$1, @@ -917,7 +918,7 @@ function stable_sort(cmp, l) { if (l2$1) { var h2 = l2$1[1]; var h1 = l1[1]; - if (cmp(h1, h2) > 0) { + if (Caml_curry.app2(cmp, h1, h2) > 0) { _accu = [ /* :: */0, h1, @@ -959,8 +960,8 @@ function stable_sort(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { + if (Caml_curry.app2(cmp, x1, x2) > 0) { + if (Caml_curry.app2(cmp, x2, x3) > 0) { return [ /* :: */0, x1, @@ -975,7 +976,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x1, x3) > 0) { + else if (Caml_curry.app2(cmp, x1, x3) > 0) { return [ /* :: */0, x1, @@ -1006,7 +1007,7 @@ function stable_sort(cmp, l) { ]; } } - else if (cmp(x1, x3) > 0) { + else if (Caml_curry.app2(cmp, x1, x3) > 0) { return [ /* :: */0, x2, @@ -1021,7 +1022,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x2, x3) > 0) { + else if (Caml_curry.app2(cmp, x2, x3) > 0) { return [ /* :: */0, x2, @@ -1069,7 +1070,7 @@ function stable_sort(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - if (cmp(x1$1, x2$1) > 0) { + if (Caml_curry.app2(cmp, x1$1, x2$1) > 0) { return [ /* :: */0, x1$1, @@ -1116,7 +1117,7 @@ function stable_sort(cmp, l) { if (l2$1) { var h2 = l2$1[1]; var h1 = l1[1]; - if (cmp(h1, h2) <= 0) { + if (Caml_curry.app2(cmp, h1, h2) <= 0) { _accu = [ /* :: */0, h1, @@ -1168,10 +1169,10 @@ function sort_uniq(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - var c = cmp(x1, x2); + var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c < 0) { - var c$1 = cmp(x2, x3); + var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 < 0) { return [ @@ -1189,7 +1190,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$2 = cmp(x1, x3); + var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 < 0) { return [ @@ -1248,7 +1249,7 @@ function sort_uniq(cmp, l) { } } else { - var c$3 = cmp(x1, x3); + var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 < 0) { return [ @@ -1266,7 +1267,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$4 = cmp(x2, x3); + var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 < 0) { return [ @@ -1326,7 +1327,7 @@ function sort_uniq(cmp, l) { } } else { - var c$5 = cmp(x2, x3); + var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 < 0) { return [ @@ -1377,7 +1378,7 @@ function sort_uniq(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - var c$6 = cmp(x1$1, x2$1); + var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 < 0) { return [ @@ -1436,7 +1437,7 @@ function sort_uniq(cmp, l) { var h2 = l2$1[1]; var t1 = l1[2]; var h1 = l1[1]; - var c$7 = cmp(h1, h2); + var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 > 0) { _accu = [ @@ -1490,10 +1491,10 @@ function sort_uniq(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - var c = cmp(x1, x2); + var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c > 0) { - var c$1 = cmp(x2, x3); + var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 > 0) { return [ @@ -1511,7 +1512,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$2 = cmp(x1, x3); + var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 > 0) { return [ @@ -1570,7 +1571,7 @@ function sort_uniq(cmp, l) { } } else { - var c$3 = cmp(x1, x3); + var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 > 0) { return [ @@ -1588,7 +1589,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$4 = cmp(x2, x3); + var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 > 0) { return [ @@ -1648,7 +1649,7 @@ function sort_uniq(cmp, l) { } } else { - var c$5 = cmp(x2, x3); + var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 > 0) { return [ @@ -1699,7 +1700,7 @@ function sort_uniq(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - var c$6 = cmp(x1$1, x2$1); + var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 > 0) { return [ @@ -1758,7 +1759,7 @@ function sort_uniq(cmp, l) { var h2 = l2$1[1]; var t1 = l1[2]; var h1 = l1[1]; - var c$7 = cmp(h1, h2); + var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 < 0) { _accu = [ diff --git a/jscomp/stdlib/map.js b/jscomp/stdlib/map.js index 97da875d76..ef379dee71 100644 --- a/jscomp/stdlib/map.js +++ b/jscomp/stdlib/map.js @@ -3,6 +3,7 @@ var Pervasives = require("./pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); function Make(funarg) { var height = function (param) { @@ -103,7 +104,7 @@ function Make(funarg) { var d = param[3]; var v = param[2]; var l = param[1]; - var c = funarg[1](x, v); + var c = Caml_curry.app2(funarg[1], x, v); if (c) { if (c < 0) { return bal(add(x, data, l), v, d, r); @@ -138,7 +139,7 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var c = funarg[1](x, param[2]); + var c = Caml_curry.app2(funarg[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; } @@ -155,7 +156,7 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var c = funarg[1](x, param[2]); + var c = Caml_curry.app2(funarg[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; } @@ -230,7 +231,7 @@ function Make(funarg) { var d = param[3]; var v = param[2]; var l = param[1]; - var c = funarg[1](x, v); + var c = Caml_curry.app2(funarg[1], x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, d, r); @@ -265,7 +266,7 @@ function Make(funarg) { var param = _param; if (param) { iter(f, param[1]); - f(param[2], param[3]); + Caml_curry.app2(f, param[2], param[3]); _param = param[4]; } else { @@ -276,7 +277,7 @@ function Make(funarg) { var map = function (f, param) { if (param) { var l$prime = map(f, param[1]); - var d$prime = f(param[3]); + var d$prime = Caml_curry.app1(f, param[3]); var r$prime = map(f, param[4]); return [ /* Node */0, @@ -295,7 +296,7 @@ function Make(funarg) { if (param) { var v = param[2]; var l$prime = mapi(f, param[1]); - var d$prime = f(v, param[3]); + var d$prime = Caml_curry.app2(f, v, param[3]); var r$prime = mapi(f, param[4]); return [ /* Node */0, @@ -315,7 +316,7 @@ function Make(funarg) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; } else { @@ -327,7 +328,7 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; } @@ -348,7 +349,7 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { return /* true */1; } else if (exists(p, param[1])) { @@ -430,7 +431,7 @@ function Make(funarg) { var d = param[3]; var v = param[2]; var l = param[1]; - var c = funarg[1](x, v); + var c = Caml_curry.app2(funarg[1], x, v); if (c) { if (c < 0) { var match = split(x, l); @@ -478,7 +479,7 @@ function Make(funarg) { var v1 = s1[2]; if (s1[5] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, f(v1, [ + 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])); @@ -497,7 +498,7 @@ function Make(funarg) { if (s2) { var v2 = s2[2]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, f(v2, match$1[2], [ + 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])); @@ -522,7 +523,7 @@ function Make(funarg) { var d = param[3]; var v = param[2]; var l$prime = filter(p, param[1]); - var pvd = p(v, d); + var pvd = Caml_curry.app2(p, v, d); var r$prime = filter(p, param[4]); if (pvd) { return join(l$prime, v, d, r$prime); @@ -542,7 +543,7 @@ function Make(funarg) { var match = partition(p, param[1]); var lf = match[2]; var lt = match[1]; - var pvd = p(v, d); + 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]; @@ -596,12 +597,12 @@ function Make(funarg) { var e1 = _e1; if (e1) { if (e2) { - var c = funarg[1](e1[1], e2[1]); + var c = Caml_curry.app2(funarg[1], e1[1], e2[1]); if (c !== 0) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -631,10 +632,10 @@ function Make(funarg) { var e1 = _e1; if (e1) { if (e2) { - if (funarg[1](e1[1], e2[1])) { + if (Caml_curry.app2(funarg[1], e1[1], e2[1])) { return /* false */0; } - else if (cmp(e1[2], e2[2])) { + else if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); } diff --git a/jscomp/stdlib/marshal.js b/jscomp/stdlib/marshal.js index 9b15f7a1b1..9bd5e1312d 100644 --- a/jscomp/stdlib/marshal.js +++ b/jscomp/stdlib/marshal.js @@ -4,6 +4,7 @@ var Bytes = require("./bytes"); var Pervasives = require("./pervasives"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); function to_buffer(buff, ofs, len, v, flags) { if (ofs < 0 || len < 0 || ofs > buff.length - len) { @@ -45,7 +46,7 @@ function from_bytes(buff, ofs) { } function from_string(buff, ofs) { - return from_bytes(Bytes.unsafe_of_string(buff), ofs); + return from_bytes(Caml_curry.app1(Bytes.unsafe_of_string, buff), ofs); } function to_channel(prim, prim$1, prim$2) { diff --git a/jscomp/stdlib/parsing.js b/jscomp/stdlib/parsing.js index de3152351f..9b332f662d 100644 --- a/jscomp/stdlib/parsing.js +++ b/jscomp/stdlib/parsing.js @@ -8,6 +8,7 @@ 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, @@ -93,7 +94,7 @@ function yyparse(tables, start, lexer, lexbuf) { var match = Caml_lexer.caml_parse_engine(tables, env, cmd, arg); switch (match) { case 0 : - var t = lexer(lexbuf); + var t = Caml_curry.app1(lexer, lexbuf); env[9] = lexbuf[11]; env[10] = lexbuf[12]; _arg = t; @@ -117,7 +118,7 @@ function yyparse(tables, start, lexer, lexbuf) { match$1 = [ /* tuple */0, /* Semantic_action_computed */4, - tables[1][env[13]](env) + Caml_curry.app1(tables[1][env[13]], env) ]; } catch (exn){ @@ -136,7 +137,7 @@ function yyparse(tables, start, lexer, lexbuf) { _cmd = match$1[1]; break; case 5 : - tables[14]("syntax error"); + Caml_curry.app1(tables[14], "syntax error"); _arg = /* () */0; _cmd = /* Error_detected */5; break; @@ -223,7 +224,7 @@ function rhs_end(n) { } function is_current_lookahead(tok) { - return current_lookahead_fun[1](tok); + return Caml_curry.app1(current_lookahead_fun[1], tok); } function parse_error() { diff --git a/jscomp/stdlib/pervasives.js b/jscomp/stdlib/pervasives.js index 188a2b70c9..37bc6fadef 100644 --- a/jscomp/stdlib/pervasives.js +++ b/jscomp/stdlib/pervasives.js @@ -6,6 +6,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_format = require("../runtime/caml_format"); var Caml_primitive = require("../runtime/caml_primitive"); var CamlinternalFormatBasics = require("./camlinternalFormatBasics"); +var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); function failwith(s) { @@ -531,14 +532,14 @@ var exit_function = [ function at_exit(f) { var g = exit_function[1]; exit_function[1] = function () { - f(/* () */0); - return g(/* () */0); + Caml_curry.app1(f, /* () */0); + return Caml_curry.app1(g, /* () */0); }; return /* () */0; } function do_at_exit() { - return exit_function[1](/* () */0); + return Caml_curry.app1(exit_function[1], /* () */0); } function exit(retcode) { diff --git a/jscomp/stdlib/printexc.js b/jscomp/stdlib/printexc.js index 7c0c253886..78a81605fd 100644 --- a/jscomp/stdlib/printexc.js +++ b/jscomp/stdlib/printexc.js @@ -9,6 +9,7 @@ var Printf = require("./printf"); var Caml_primitive = require("../runtime/caml_primitive"); var $$Array = require("./array"); var Buffer = require("./buffer"); +var Caml_curry = require("../runtime/caml_curry"); var printers = [ 0, @@ -71,15 +72,15 @@ 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 Printf.sprintf([ - /* Format */0, - [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ], - "%S" - ])(f); + return Caml_curry.app1(Printf.sprintf([ + /* Format */0, + [ + /* Caml_string */3, + /* No_padding */0, + /* End_of_format */0 + ], + "%S" + ]), f); } else if (Caml_obj_runtime.caml_obj_tag(f) === Obj.double_tag) { return Pervasives.string_of_float(f); @@ -89,17 +90,17 @@ function field(x, i) { } } else { - return 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 */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, + /* End_of_format */0 + ], + "%d" + ]), f); } } @@ -108,50 +109,50 @@ function other_fields(x, i) { return ""; } else { - return Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - ", ", + return Caml_curry.app2(Printf.sprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ", ", [ /* String */2, /* No_padding */0, - /* End_of_format */0 + [ + /* String */2, + /* No_padding */0, + /* End_of_format */0 + ] ] - ] - ], - ", %s%s" - ])(field(x, i), other_fields(x, i + 1)); + ], + ", %s%s" + ]), field(x, i), other_fields(x, i + 1)); } } function fields(x) { var n = x.length; if (n > 2 || n < 0) { - return Printf.sprintf([ - /* Format */0, - [ - /* Char_literal */12, - /* "(" */40, + return Caml_curry.app2(Printf.sprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* Char_literal */12, + /* "(" */40, [ /* String */2, /* No_padding */0, [ - /* Char_literal */12, - /* ")" */41, - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* ")" */41, + /* End_of_format */0 + ] ] ] - ] - ], - "(%s%s)" - ])(field(x, 1), other_fields(x, 2)); + ], + "(%s%s)" + ]), field(x, 1), other_fields(x, 2)); } else { switch (n) { @@ -159,23 +160,23 @@ function fields(x) { case 1 : return ""; case 2 : - return Printf.sprintf([ - /* Format */0, - [ - /* Char_literal */12, - /* "(" */40, + return Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* Char_literal */12, + /* "(" */40, [ - /* Char_literal */12, - /* ")" */41, - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* ")" */41, + /* End_of_format */0 + ] ] - ] - ], - "(%s)" - ])(field(x, 1)); + ], + "(%s)" + ]), field(x, 1)); } } @@ -188,7 +189,7 @@ function to_string(x) { if (param) { var match; try { - match = param[1](x); + match = Caml_curry.app1(param[1], x); } catch (exn){ match = /* None */0; @@ -209,17 +210,17 @@ function to_string(x) { else if (x[1] === Caml_exceptions.Match_failure) { var match$1 = x[2]; var $$char = match$1[3]; - return Printf.sprintf(locfmt)(match$1[1], match$1[2], $$char, $$char + 5, "Pattern matching failed"); + return Caml_curry.app5(Printf.sprintf(locfmt), match$1[1], match$1[2], $$char, $$char + 5, "Pattern matching failed"); } else if (x[1] === Caml_exceptions.Assert_failure) { var match$2 = x[2]; var $$char$1 = match$2[3]; - return Printf.sprintf(locfmt)(match$2[1], match$2[2], $$char$1, $$char$1 + 6, "Assertion failed"); + return Caml_curry.app5(Printf.sprintf(locfmt), match$2[1], match$2[2], $$char$1, $$char$1 + 6, "Assertion failed"); } else if (x[1] === Caml_exceptions.Undefined_recursive_module) { var match$3 = x[2]; var $$char$2 = match$3[3]; - return Printf.sprintf(locfmt)(match$3[1], match$3[2], $$char$2, $$char$2 + 6, "Undefined recursive module"); + return Caml_curry.app5(Printf.sprintf(locfmt), match$3[1], match$3[2], $$char$2, $$char$2 + 6, "Undefined recursive module"); } else if (Caml_obj_runtime.caml_obj_tag(x) !== 0) { return x[0]; @@ -233,54 +234,54 @@ function to_string(x) { function print(fct, arg) { try { - return fct(arg); + return Caml_curry.app1(fct, arg); } catch (x){ - Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "Uncaught exception: ", + Caml_curry.app1(Printf.eprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "Uncaught exception: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] ] - ] - ], - "Uncaught exception: %s\n" - ])(to_string(x)); - Pervasives.flush(Pervasives.stderr); + ], + "Uncaught exception: %s\n" + ]), to_string(x)); + Caml_curry.app1(Pervasives.flush, Pervasives.stderr); throw x; } } function $$catch(fct, arg) { try { - return fct(arg); + return Caml_curry.app1(fct, arg); } catch (x){ - Pervasives.flush(Pervasives.stdout); - Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "Uncaught exception: ", + Caml_curry.app1(Pervasives.flush, Pervasives.stdout); + Caml_curry.app1(Printf.eprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "Uncaught exception: ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] ] - ] - ], - "Uncaught exception: %s\n" - ])(to_string(x)); + ], + "Uncaught exception: %s\n" + ]), to_string(x)); return Pervasives.exit(2); } } @@ -328,61 +329,62 @@ function format_backtrace_slot(pos, slot) { else { return [ /* Some */0, - Printf.sprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* String_literal */11, - " unknown location", - /* End_of_format */0 - ] - ], - "%s unknown location" - ])(info(/* false */0)) + /* String */2, + /* No_padding */0, + [ + /* String_literal */11, + " unknown location", + /* End_of_format */0 + ] + ], + "%s unknown location" + ]), info(/* false */0)) ]; } } else { return [ /* Some */0, - Printf.sprintf([ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app5(Printf.sprintf([ + /* Format */0, [ - /* String_literal */11, - ' file "', + /* String */2, + /* No_padding */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + ' file "', [ - /* String_literal */11, - '", line ', + /* String */2, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + '", line ', [ - /* String_literal */11, - ", characters ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + ", characters ", [ - /* Char_literal */12, - /* "-" */45, + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 + /* Char_literal */12, + /* "-" */45, + [ + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, + /* End_of_format */0 + ] ] ] ] @@ -390,10 +392,9 @@ function format_backtrace_slot(pos, slot) { ] ] ] - ] - ], - '%s file "%s", line %d, characters %d-%d' - ])(info(slot[1]), slot[2], slot[3], slot[4], slot[5]) + ], + '%s file "%s", line %d, characters %d-%d' + ]), info(slot[1]), slot[2], slot[3], slot[4], slot[5]) ]; } } @@ -406,19 +407,19 @@ function print_raw_backtrace(outchan, raw_backtrace) { for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ var match = format_backtrace_slot(i, a[i]); if (match) { - Printf.fprintf(outchan$1, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app1(Printf.fprintf(outchan$1, [ + /* Format */0, [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ], - "%s\n" - ])(match[1]); + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] + ], + "%s\n" + ]), match[1]); } } @@ -448,19 +449,19 @@ function backtrace_to_string(backtrace) { for(var i = 0 ,i_finish = a.length - 1; i<= i_finish; ++i){ var match = format_backtrace_slot(i, a[i]); if (match) { - Printf.bprintf(b, [ - /* Format */0, - [ - /* String */2, - /* No_padding */0, + Caml_curry.app1(Printf.bprintf(b, [ + /* Format */0, [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 - ] - ], - "%s\n" - ])(match[1]); + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] + ], + "%s\n" + ]), match[1]); } } diff --git a/jscomp/stdlib/printf.js b/jscomp/stdlib/printf.js index b4d4b74b90..700027b52c 100644 --- a/jscomp/stdlib/printf.js +++ b/jscomp/stdlib/printf.js @@ -3,25 +3,26 @@ var Pervasives = require("./pervasives"); var Buffer = require("./buffer"); +var Caml_curry = require("../runtime/caml_curry"); var CamlinternalFormat = require("./camlinternalFormat"); function kfprintf(k, o, param) { return CamlinternalFormat.make_printf(function (o, acc) { CamlinternalFormat.output_acc(o, acc); - return k(o); + return Caml_curry.app1(k, o); }, o, /* End_of_acc */0, param[1]); } function kbprintf(k, b, param) { return CamlinternalFormat.make_printf(function (b, acc) { CamlinternalFormat.bufput_acc(b, acc); - return k(b); + return Caml_curry.app1(k, b); }, b, /* End_of_acc */0, param[1]); } function ikfprintf(k, oc, param) { return CamlinternalFormat.make_printf(function (oc, _) { - return k(oc); + return Caml_curry.app1(k, oc); }, oc, /* End_of_acc */0, param[1]); } @@ -55,7 +56,7 @@ function ksprintf(k, param) { var k$prime = function (_, acc) { var buf = Buffer.create(64); CamlinternalFormat.strput_acc(buf, acc); - return k(Buffer.contents(buf)); + return Caml_curry.app1(k, Buffer.contents(buf)); }; return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[1]); } diff --git a/jscomp/stdlib/queue.js b/jscomp/stdlib/queue.js index 5a26ce7fca..db3bc050ff 100644 --- a/jscomp/stdlib/queue.js +++ b/jscomp/stdlib/queue.js @@ -3,6 +3,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); var Empty = [ 248, @@ -134,7 +135,7 @@ function iter(f, q) { var _cell = tail[2]; while(true) { var cell = _cell; - f(cell[1]); + Caml_curry.app1(f, cell[1]); if (cell !== tail) { _cell = cell[2]; } @@ -156,7 +157,7 @@ function fold(f, accu, q) { while(true) { var cell = _cell; var accu$1 = _accu; - var accu$2 = f(accu$1, cell[1]); + var accu$2 = Caml_curry.app2(f, accu$1, cell[1]); if (cell === tail) { return accu$2; } diff --git a/jscomp/stdlib/random.js b/jscomp/stdlib/random.js index 720ae46f4d..1a08b53c04 100644 --- a/jscomp/stdlib/random.js +++ b/jscomp/stdlib/random.js @@ -9,6 +9,7 @@ var Digest = require("./digest"); var Int64 = require("./int64"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("./array"); +var Caml_curry = require("../runtime/caml_curry"); function new_state() { return [ @@ -227,7 +228,7 @@ function int32$1(bound) { } function nativeint$1(bound) { - return nativeint($$default, bound); + return Caml_curry.app2(nativeint, $$default, bound); } function int64$1(bound) { diff --git a/jscomp/stdlib/scanf.js b/jscomp/stdlib/scanf.js index e69c89afc0..9569f5d7c5 100644 --- a/jscomp/stdlib/scanf.js +++ b/jscomp/stdlib/scanf.js @@ -8,6 +8,7 @@ var Printf = require("./printf"); var Caml_primitive = require("../runtime/caml_primitive"); var CamlinternalFormatBasics = require("./camlinternalFormatBasics"); var Buffer = require("./buffer"); +var Caml_curry = require("../runtime/caml_curry"); var $$String = require("./string"); var Caml_string = require("../runtime/caml_string"); var List = require("./list"); @@ -17,7 +18,7 @@ var null_char = /* "\000" */0; function next_char(ib) { try { - var c = ib[7](/* () */0); + var c = Caml_curry.app1(ib[7], /* () */0); ib[2] = c; ib[3] = /* true */1; ++ ib[4]; @@ -155,7 +156,7 @@ var file_buffer_size = [ ]; function scan_close_at_end(ic) { - Pervasives.close_in(ic); + Caml_curry.app1(Pervasives.close_in, ic); throw Caml_exceptions.End_of_file; } @@ -195,7 +196,7 @@ function from_ic(scan_close_ic, iname, ic) { } else { eof[1] = /* true */1; - return scan_close_ic(ic); + return Caml_curry.app1(scan_close_ic, ic); } } }; @@ -278,10 +279,10 @@ function close_in(ib) { return /* () */0; } else if (match[0]) { - return Pervasives.close_in(match[1]); + return Caml_curry.app1(Pervasives.close_in, match[1]); } else { - return Pervasives.close_in(match[2]); + return Caml_curry.app1(Pervasives.close_in, match[2]); } } @@ -292,18 +293,18 @@ var Scan_failure = [ ]; function bad_input_escape(c) { - var s = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "illegal escape character ", + var s = Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* Caml_char */1, - /* End_of_format */0 - ] - ], - "illegal escape character %C" - ])(c); + /* String_literal */11, + "illegal escape character ", + [ + /* Caml_char */1, + /* End_of_format */0 + ] + ], + "illegal escape character %C" + ]), c); throw [ 0, Scan_failure, @@ -312,23 +313,23 @@ function bad_input_escape(c) { } function bad_token_length(message) { - var s = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "scanning of ", + var s = Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "scanning of ", [ - /* String_literal */11, - " failed: the specified length was too short for token", - /* End_of_format */0 + /* 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); + ], + "scanning of %s failed: the specified length was too short for token" + ]), message); throw [ 0, Scan_failure, @@ -337,25 +338,25 @@ function bad_token_length(message) { } function character_mismatch_err(c, ci) { - return Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "looking for ", + return Caml_curry.app2(Printf.sprintf([ + /* Format */0, [ - /* Caml_char */1, + /* String_literal */11, + "looking for ", [ - /* String_literal */11, - ", found ", + /* Caml_char */1, [ - /* Caml_char */1, - /* End_of_format */0 + /* String_literal */11, + ", found ", + [ + /* Caml_char */1, + /* End_of_format */0 + ] ] ] - ] - ], - "looking for %C, found %C" - ])(c, ci); + ], + "looking for %C, found %C" + ]), c, ci); } function check_char(ib, _c) { @@ -429,19 +430,19 @@ function token_bool(ib) { case "true" : return /* true */1; default: - var s$1 = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "invalid boolean ", + var s$1 = Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "invalid boolean %S" - ])(s); + /* String_literal */11, + "invalid boolean ", + [ + /* Caml_string */3, + /* No_padding */0, + /* End_of_format */0 + ] + ], + "invalid boolean %S" + ]), s); throw [ 0, Scan_failure, @@ -565,22 +566,22 @@ function scan_decimal_digits_plus(width, ib) { if (width) { var c = checked_peek_char(ib); if (c > 57 || c < 48) { - var s = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "character ", + var s = Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* Caml_char */1, + /* String_literal */11, + "character ", [ - /* String_literal */11, - " is not a decimal digit", - /* End_of_format */0 + /* Caml_char */1, + [ + /* String_literal */11, + " is not a decimal digit", + /* End_of_format */0 + ] ] - ] - ], - "character %C is not a decimal digit" - ])(c); + ], + "character %C is not a decimal digit" + ]), c); throw [ 0, Scan_failure, @@ -600,7 +601,7 @@ function scan_decimal_digits_plus(width, ib) { function scan_digits_plus(basis, digitp, width, ib) { if (width) { var c = checked_peek_char(ib); - if (digitp(c)) { + if (Caml_curry.app1(digitp, c)) { var _width = store_char(width, ib, c); while(true) { var width$1 = _width; @@ -609,7 +610,7 @@ function scan_digits_plus(basis, digitp, width, ib) { if (ib[1]) { return width$1; } - else if (digitp(c$1)) { + else if (Caml_curry.app1(digitp, c$1)) { _width = store_char(width$1, ib, c$1); } else if (c$1 !== 95) { @@ -625,30 +626,30 @@ function scan_digits_plus(basis, digitp, width, ib) { }; } else { - var s = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "character ", + var s = Caml_curry.app2(Printf.sprintf([ + /* Format */0, [ - /* Caml_char */1, + /* String_literal */11, + "character ", [ - /* String_literal */11, - " is not a valid ", + /* Caml_char */1, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + " is not a valid ", [ - /* String_literal */11, - " digit", - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* String_literal */11, + " digit", + /* End_of_format */0 + ] ] ] ] - ] - ], - "character %C is not a valid %s digit" - ])(c, basis); + ], + "character %C is not a valid %s digit" + ]), c, basis); throw [ 0, Scan_failure, @@ -1044,24 +1045,24 @@ 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 = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "bad character decimal encoding \\", + var s = Caml_curry.app3(Printf.sprintf([ + /* Format */0, [ - /* Char */0, + /* String_literal */11, + "bad character decimal encoding \\", [ /* Char */0, [ /* Char */0, - /* End_of_format */0 + [ + /* Char */0, + /* End_of_format */0 + ] ] ] - ] - ], - "bad character decimal encoding \\%c%c%c" - ])(c0, c1, c2); + ], + "bad character decimal encoding \\%c%c%c" + ]), c0, c1, c2); throw [ 0, Scan_failure, @@ -1088,21 +1089,21 @@ 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 = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "bad character hexadecimal encoding \\", + var s = Caml_curry.app2(Printf.sprintf([ + /* Format */0, [ - /* Char */0, + /* String_literal */11, + "bad character hexadecimal encoding \\", [ /* Char */0, - /* End_of_format */0 + [ + /* Char */0, + /* End_of_format */0 + ] ] - ] - ], - "bad character hexadecimal encoding \\%c%c" - ])(c1, c2); + ], + "bad character hexadecimal encoding \\%c%c" + ]), c1, c2); throw [ 0, Scan_failure, @@ -1119,23 +1120,23 @@ function check_next_char(message, width, ib) { var c = peek_char(ib); if (ib[1]) { var message$1 = message; - var s = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "scanning of ", + var s = Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "scanning of ", [ - /* String_literal */11, - " failed: premature end of file occurred before end of token", - /* End_of_format */0 + /* 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); + ], + "scanning of %s failed: premature end of file occurred before end of token" + ]), message$1); throw [ 0, Scan_failure, @@ -1353,22 +1354,22 @@ function scan_bool(ib) { var m; if (c !== 102) { if (c !== 116) { - var s = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "the character ", + var s = Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* Caml_char */1, + /* String_literal */11, + "the character ", [ - /* String_literal */11, - " cannot start a boolean", - /* End_of_format */0 + /* Caml_char */1, + [ + /* String_literal */11, + " cannot start a boolean", + /* End_of_format */0 + ] ] - ] - ], - "the character %C cannot start a boolean" - ])(c); + ], + "the character %C cannot start a boolean" + ]), c); throw [ 0, Scan_failure, @@ -1442,29 +1443,29 @@ function scanf_bad_input(ib, x) { } if (exit === 1) { var i = char_count(ib); - var s$1 = Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "scanf: bad input at char number ", + var s$1 = Caml_curry.app2(Printf.sprintf([ + /* Format */0, [ - /* Int */4, - /* Int_i */3, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "scanf: bad input at char number ", [ - /* String_literal */11, - ": ", + /* Int */4, + /* Int_i */3, + /* No_padding */0, + /* No_precision */0, [ - /* Caml_string */3, - /* No_padding */0, - /* End_of_format */0 + /* String_literal */11, + ": ", + [ + /* Caml_string */3, + /* No_padding */0, + /* End_of_format */0 + ] ] ] - ] - ], - "scanf: bad input at char number %i: %S" - ])(i, s); + ], + "scanf: bad input at char number %i: %S" + ]), i, s); throw [ 0, Scan_failure, @@ -1519,7 +1520,7 @@ function take_format_readers(k, _fmt) { while(true) { var fmt = _fmt; if (typeof fmt === "number") { - return k(/* Nil */0); + return Caml_curry.app1(k, /* Nil */0); } else { switch (fmt[0]) { @@ -1541,7 +1542,7 @@ function take_format_readers(k, _fmt) { return (function(fmt_rest){ return function (reader) { var new_k = function (readers_rest) { - return k([ + return Caml_curry.app1(k, [ /* Cons */0, reader, readers_rest @@ -1577,7 +1578,7 @@ function take_format_readers(k, _fmt) { return (function(k$1,fmt$1){ return function (reader) { var new_k = function (readers_rest) { - return k$1([ + return Caml_curry.app1(k$1, [ /* Cons */0, reader, readers_rest @@ -1656,7 +1657,7 @@ function take_fmtty_format_readers(k, _fmtty, fmt) { return (function(fmt_rest){ return function (reader) { var new_k = function (readers_rest) { - return k([ + return Caml_curry.app1(k, [ /* Cons */0, reader, readers_rest @@ -1670,7 +1671,7 @@ function take_fmtty_format_readers(k, _fmtty, fmt) { return (function(fmt_rest$1){ return function (reader) { var new_k = function (readers_rest) { - return k([ + return Caml_curry.app1(k, [ /* Cons */0, reader, readers_rest @@ -1941,7 +1942,7 @@ function make_scanf(ib, _fmt, readers) { } break; case 19 : - var x = readers[1](ib); + var x = Caml_curry.app1(readers[1], ib); return [ /* Cons */0, x, @@ -2038,8 +2039,8 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { return Pervasives.invalid_arg('scanf: bad conversion "%*"'); } else { - scan(Pervasives.max_int, Pervasives.max_int, ib); - var x = token(ib); + Caml_curry.app3(scan, Pervasives.max_int, Pervasives.max_int, ib); + var x = Caml_curry.app1(token, ib); return [ /* Cons */0, x, @@ -2048,8 +2049,8 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { } } else { - scan(Pervasives.max_int, prec[1], ib); - var x$1 = token(ib); + Caml_curry.app3(scan, Pervasives.max_int, prec[1], ib); + var x$1 = Caml_curry.app1(token, ib); return [ /* Cons */0, x$1, @@ -2067,8 +2068,8 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { return Pervasives.invalid_arg('scanf: bad conversion "%*"'); } else { - scan(w, Pervasives.max_int, ib); - var x$2 = token(ib); + Caml_curry.app3(scan, w, Pervasives.max_int, ib); + var x$2 = Caml_curry.app1(token, ib); return [ /* Cons */0, x$2, @@ -2077,8 +2078,8 @@ function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { } } else { - scan(w, prec[1], ib); - var x$3 = token(ib); + Caml_curry.app3(scan, w, prec[1], ib); + var x$3 = Caml_curry.app1(token, ib); return [ /* Cons */0, x$3, @@ -2130,7 +2131,7 @@ function kscanf(ib, ef, param) { } } if (match[0]) { - return ef(ib, match[1]); + return Caml_curry.app2(ef, ib, match[1]); } else { var _f = f; @@ -2140,7 +2141,7 @@ function kscanf(ib, ef, param) { var f$1 = _f; if (args) { _args = args[2]; - _f = f$1(args[1]); + _f = Caml_curry.app1(f$1, args[1]); } else { return f$1; @@ -2194,7 +2195,7 @@ function bscanf_format(ib, format, f) { throw exn; } } - return f($js); + return Caml_curry.app1(f, $js); } function sscanf_format(s, format, f) { @@ -2223,18 +2224,18 @@ function format_from_string(s, fmt) { } function unescaped(s) { - return sscanf('"' + (s + '"'), [ - /* Format */0, - [ - /* Caml_string */3, - /* No_padding */0, + return Caml_curry.app1(sscanf('"' + (s + '"'), [ + /* Format */0, [ - /* Flush */10, - /* End_of_format */0 - ] - ], - "%S%!" - ])(function (x) { + /* Caml_string */3, + /* No_padding */0, + [ + /* Flush */10, + /* End_of_format */0 + ] + ], + "%S%!" + ]), function (x) { return x; }); } diff --git a/jscomp/stdlib/set.js b/jscomp/stdlib/set.js index 7bf2f91779..afc58fe0f6 100644 --- a/jscomp/stdlib/set.js +++ b/jscomp/stdlib/set.js @@ -3,6 +3,7 @@ var Pervasives = require("./pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("./list"); function Make(funarg) { @@ -81,7 +82,7 @@ function Make(funarg) { var r = t[3]; var v = t[2]; var l = t[1]; - var c = funarg[1](x, v); + var c = Caml_curry.app2(funarg[1], x, v); if (c) { if (c < 0) { return bal(add(x, l), v, r); @@ -218,7 +219,7 @@ function Make(funarg) { var r = param[3]; var v = param[2]; var l = param[1]; - var c = funarg[1](x, v); + var c = Caml_curry.app2(funarg[1], x, v); if (c) { if (c < 0) { var match = split(x, l); @@ -270,7 +271,7 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - var c = funarg[1](x, param[2]); + var c = Caml_curry.app2(funarg[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[3]; } @@ -288,7 +289,7 @@ function Make(funarg) { var r = param[3]; var v = param[2]; var l = param[1]; - var c = funarg[1](x, v); + var c = Caml_curry.app2(funarg[1], x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, r); @@ -421,7 +422,7 @@ function Make(funarg) { var e1 = _e1; if (e1) { if (e2) { - var c = funarg[1](e1[1], e2[1]); + var c = Caml_curry.app2(funarg[1], e1[1], e2[1]); if (c !== 0) { return c; } @@ -456,7 +457,7 @@ function Make(funarg) { var r1 = s1[3]; var v1 = s1[2]; var l1 = s1[1]; - var c = funarg[1](v1, s2[2]); + var c = Caml_curry.app2(funarg[1], v1, s2[2]); if (c) { if (c < 0) { if (subset([ @@ -507,7 +508,7 @@ function Make(funarg) { var param = _param; if (param) { iter(f, param[1]); - f(param[2]); + Caml_curry.app1(f, param[2]); _param = param[3]; } else { @@ -520,7 +521,7 @@ function Make(funarg) { var accu = _accu; var s = _s; if (s) { - _accu = f(s[2], fold(f, s[1], accu)); + _accu = Caml_curry.app2(f, s[2], fold(f, s[1], accu)); _s = s[3]; } else { @@ -532,7 +533,7 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (p(param[2])) { + if (Caml_curry.app1(p, param[2])) { if (for_all(p, param[1])) { _param = param[3]; } @@ -553,7 +554,7 @@ function Make(funarg) { while(true) { var param = _param; if (param) { - if (p(param[2])) { + if (Caml_curry.app1(p, param[2])) { return /* true */1; } else if (exists(p, param[1])) { @@ -572,7 +573,7 @@ function Make(funarg) { if (param) { var v = param[2]; var l$prime = filter(p, param[1]); - var pv = p(v); + var pv = Caml_curry.app1(p, v); var r$prime = filter(p, param[3]); if (pv) { return join(l$prime, v, r$prime); @@ -591,7 +592,7 @@ function Make(funarg) { var match = partition(p, param[1]); var lf = match[2]; var lt = match[1]; - var pv = p(v); + var pv = Caml_curry.app1(p, v); var match$1 = partition(p, param[3]); var rf = match$1[2]; var rt = match$1[1]; @@ -651,7 +652,7 @@ function Make(funarg) { var param = _param; if (param) { var v = param[2]; - var c = funarg[1](x, v); + var c = Caml_curry.app2(funarg[1], x, v); if (c) { _param = c < 0 ? param[1] : param[3]; } diff --git a/jscomp/stdlib/sort.js b/jscomp/stdlib/sort.js index a5fa6cec37..c0a9b0269c 100644 --- a/jscomp/stdlib/sort.js +++ b/jscomp/stdlib/sort.js @@ -2,13 +2,14 @@ 'use strict'; var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); function merge(order, l1, l2) { if (l1) { var h1 = l1[1]; if (l2) { var h2 = l2[1]; - if (order(h1, h2)) { + if (Caml_curry.app2(order, h1, h2)) { return [ /* :: */0, h1, @@ -41,7 +42,7 @@ function list(order, l) { var e2 = match[1]; return [ /* :: */0, - order(e, e2) ? [ + Caml_curry.app2(order, e, e2) ? [ /* :: */0, e, [ @@ -126,12 +127,12 @@ function array(cmp, arr) { var lo = _lo; if (hi - lo >= 6) { var mid = (lo + hi >>> 1); - if (cmp(arr[mid], arr[lo])) { + if (Caml_curry.app2(cmp, arr[mid], arr[lo])) { swap(arr, mid, lo); } - if (cmp(arr[hi], arr[mid])) { + if (Caml_curry.app2(cmp, arr[hi], arr[mid])) { swap(arr, mid, hi); - if (cmp(arr[mid], arr[lo])) { + if (Caml_curry.app2(cmp, arr[mid], arr[lo])) { swap(arr, mid, lo); } @@ -139,7 +140,7 @@ function array(cmp, arr) { var pivot = arr[mid]; var i = lo + 1; var j = hi - 1; - if (!cmp(pivot, arr[hi]) || !cmp(arr[lo], pivot)) { + if (!Caml_curry.app2(cmp, pivot, arr[hi]) || !Caml_curry.app2(cmp, arr[lo], pivot)) { throw [ 0, Caml_exceptions.Invalid_argument, @@ -147,10 +148,10 @@ function array(cmp, arr) { ]; } while(i < j) { - while(!cmp(pivot, arr[i])) { + while(!Caml_curry.app2(cmp, pivot, arr[i])) { ++ i; }; - while(!cmp(arr[j], pivot)) { + while(!Caml_curry.app2(cmp, arr[j], pivot)) { -- j; }; if (i < j) { @@ -176,10 +177,10 @@ function array(cmp, arr) { qsort(0, arr.length - 1); for(var i = 1 ,i_finish = arr.length - 1; i<= i_finish; ++i){ var val_i = arr[i]; - if (!cmp(arr[i - 1], val_i)) { + if (!Caml_curry.app2(cmp, arr[i - 1], val_i)) { arr[i] = arr[i - 1]; var j = i - 1; - while(j >= 1 && !cmp(arr[j - 1], val_i)) { + while(j >= 1 && !Caml_curry.app2(cmp, arr[j - 1], val_i)) { arr[j] = arr[j - 1]; -- j; }; diff --git a/jscomp/stdlib/stream.js b/jscomp/stdlib/stream.js index 3ae965ea56..99e8a92eda 100644 --- a/jscomp/stdlib/stream.js +++ b/jscomp/stdlib/stream.js @@ -5,6 +5,7 @@ var Caml_obj_runtime = require("../runtime/caml_obj_runtime"); var CamlinternalLazy = require("./camlinternalLazy"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Pervasives = require("./pervasives"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("./list"); var Failure = [ @@ -104,7 +105,7 @@ function get_data(count, _d) { } } else { - var match$3 = g[2](count); + var match$3 = Caml_curry.app1(g[2], count); if (match$3) { return [ /* Scons */0, @@ -212,7 +213,7 @@ function peek(s) { return match$1[1]; } else { - var x = g[2](s[1]); + var x = Caml_curry.app1(g[2], s[1]); g[1] = [ /* Some */0, x @@ -361,7 +362,7 @@ function iter(f, strm) { var match = peek(strm); if (match) { junk(strm); - f(match[1]); + Caml_curry.app1(f, match[1]); _param = /* () */0; } else { @@ -503,7 +504,7 @@ function lapp(f, s) { function () { return [ /* Sapp */1, - f(/* () */0)[2], + Caml_curry.app1(f, /* () */0)[2], s[2] ]; } @@ -523,7 +524,7 @@ function lcons(f, s) { function () { return [ /* Scons */0, - f(/* () */0), + Caml_curry.app1(f, /* () */0), s[2] ]; } @@ -543,7 +544,7 @@ function lsing(f) { function () { return [ /* Scons */0, - f(/* () */0), + Caml_curry.app1(f, /* () */0), /* Sempty */0 ]; } @@ -561,7 +562,7 @@ function slazy(f) { [ 246, function () { - return f(/* () */0)[2]; + return Caml_curry.app1(f, /* () */0)[2]; } ] ] @@ -585,7 +586,7 @@ function dump_data(f, param) { switch (param[0]) { case 0 : Pervasives.print_string("Scons ("); - f(param[1]); + Caml_curry.app1(f, param[1]); Pervasives.print_string(", "); dump_data(f, param[2]); return Pervasives.print_string(")"); diff --git a/jscomp/stdlib/string.js b/jscomp/stdlib/string.js index 58233904a3..9d3816643e 100644 --- a/jscomp/stdlib/string.js +++ b/jscomp/stdlib/string.js @@ -2,6 +2,7 @@ 'use strict'; var Bytes = require("./bytes"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("./list"); var Caml_string = require("../runtime/caml_string"); @@ -10,19 +11,19 @@ var bts = Bytes.unsafe_to_string; var bos = Bytes.unsafe_of_string; function make(n, c) { - return bts(Bytes.make(n, c)); + return Caml_curry.app1(bts, Bytes.make(n, c)); } function init(n, f) { - return bts(Bytes.init(n, f)); + return Caml_curry.app1(bts, Bytes.init(n, f)); } function copy(s) { - return bts(Bytes.copy(bos(s))); + return Caml_curry.app1(bts, Bytes.copy(Caml_curry.app1(bos, s))); } function sub(s, ofs, len) { - return bts(Bytes.sub(bos(s), ofs, len)); + return Caml_curry.app1(bts, Bytes.sub(Caml_curry.app1(bos, s), ofs, len)); } function concat(sep, l) { @@ -54,7 +55,7 @@ function concat(sep, l) { pos[1] += s.length; return /* () */0; }, l[2]); - return Bytes.unsafe_to_string(r); + return Caml_curry.app1(Bytes.unsafe_to_string, r); } else { return ""; @@ -62,19 +63,19 @@ function concat(sep, l) { } function iter(f, s) { - return Bytes.iter(f, bos(s)); + return Bytes.iter(f, Caml_curry.app1(bos, s)); } function iteri(f, s) { - return Bytes.iteri(f, bos(s)); + return Bytes.iteri(f, Caml_curry.app1(bos, s)); } function map(f, s) { - return bts(Bytes.map(f, bos(s))); + return Caml_curry.app1(bts, Bytes.map(f, Caml_curry.app1(bos, s))); } function mapi(f, s) { - return bts(Bytes.mapi(f, bos(s))); + return Caml_curry.app1(bts, Bytes.mapi(f, Caml_curry.app1(bos, s))); } function is_space(param) { @@ -100,7 +101,7 @@ function trim(s) { return s; } else { - return bts(Bytes.trim(bos(s))); + return Caml_curry.app1(bts, Bytes.trim(Caml_curry.app1(bos, s))); } } @@ -154,7 +155,7 @@ function escaped(s) { }; }; if (needs_escape(0)) { - return bts(Bytes.escaped(bos(s))); + return Caml_curry.app1(bts, Bytes.escaped(Caml_curry.app1(bos, s))); } else { return s; @@ -162,47 +163,47 @@ function escaped(s) { } function index(s, c) { - return Bytes.index(bos(s), c); + return Bytes.index(Caml_curry.app1(bos, s), c); } function rindex(s, c) { - return Bytes.rindex(bos(s), c); + return Bytes.rindex(Caml_curry.app1(bos, s), c); } function index_from(s, i, c) { - return Bytes.index_from(bos(s), i, c); + return Bytes.index_from(Caml_curry.app1(bos, s), i, c); } function rindex_from(s, i, c) { - return Bytes.rindex_from(bos(s), i, c); + return Bytes.rindex_from(Caml_curry.app1(bos, s), i, c); } function contains(s, c) { - return Bytes.contains(bos(s), c); + return Bytes.contains(Caml_curry.app1(bos, s), c); } function contains_from(s, i, c) { - return Bytes.contains_from(bos(s), i, c); + return Bytes.contains_from(Caml_curry.app1(bos, s), i, c); } function rcontains_from(s, i, c) { - return Bytes.rcontains_from(bos(s), i, c); + return Bytes.rcontains_from(Caml_curry.app1(bos, s), i, c); } function uppercase(s) { - return bts(Bytes.uppercase(bos(s))); + return Caml_curry.app1(bts, Bytes.uppercase(Caml_curry.app1(bos, s))); } function lowercase(s) { - return bts(Bytes.lowercase(bos(s))); + return Caml_curry.app1(bts, Bytes.lowercase(Caml_curry.app1(bos, s))); } function capitalize(s) { - return bts(Bytes.capitalize(bos(s))); + return Caml_curry.app1(bts, Bytes.capitalize(Caml_curry.app1(bos, s))); } function uncapitalize(s) { - return bts(Bytes.uncapitalize(bos(s))); + return Caml_curry.app1(bts, Bytes.uncapitalize(Caml_curry.app1(bos, s))); } function compare(x, y) { diff --git a/jscomp/stdlib/weak.js b/jscomp/stdlib/weak.js index d4cab26f4f..eb57e5931b 100644 --- a/jscomp/stdlib/weak.js +++ b/jscomp/stdlib/weak.js @@ -8,6 +8,7 @@ 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"); function length(x) { return x.length - 1; @@ -71,7 +72,7 @@ function Make(H) { else { var match = Caml_primitive.caml_weak_get(b, i); if (match) { - _accu = f(match[1], accu); + _accu = Caml_curry.app2(f, match[1], accu); _i = i + 1; } else { @@ -93,7 +94,7 @@ function Make(H) { else { var match = Caml_primitive.caml_weak_get(b, i); if (match) { - f(match[1]); + Caml_curry.app1(f, match[1]); _i = i + 1; } else { @@ -116,7 +117,7 @@ function Make(H) { else { var match = Caml_primitive.caml_weak_check(b, i); if (match !== 0) { - f(b, t[2][j], i); + Caml_curry.app3(f, b, t[2][j], i); _i = i + 1; } else { @@ -215,7 +216,7 @@ function Make(H) { var newhashes = Caml_array.caml_make_vect(newsz, 0); Caml_primitive.caml_weak_blit(bucket, 0, newbucket, 0, sz); $$Array.blit(hashes, 0, newhashes, 0, sz); - setter(newbucket, sz, d); + Caml_curry.app3(setter, newbucket, sz, d); newhashes[sz] = h; t[1][index] = newbucket; t[2][index] = newhashes; @@ -262,14 +263,14 @@ function Make(H) { _i = i + 1; } else { - setter(bucket, i, d); + Caml_curry.app3(setter, bucket, i, d); hashes[i] = h; return /* () */0; } }; }; var add = function (t, d) { - var h = H[2](d); + var h = Caml_curry.app1(H[2], d); return add_aux(t, function (prim, prim$1, prim$2) { return Caml_primitive.caml_weak_set(prim, prim$1, prim$2); }, [ @@ -278,7 +279,7 @@ function Make(H) { ], h, get_index(t, h)); }; var find_or = function (t, d, ifnotfound) { - var h = H[2](d); + var h = Caml_curry.app1(H[2], d); var index = get_index(t, h); var bucket = t[1][index]; var hashes = t[2][index]; @@ -287,12 +288,12 @@ function Make(H) { while(true) { var i = _i; if (i >= sz) { - return ifnotfound(h, index); + return Caml_curry.app2(ifnotfound, h, index); } else if (h === hashes[i]) { var match = Caml_primitive.caml_weak_get_copy(bucket, i); if (match) { - if (H[1](match[1], d)) { + if (Caml_curry.app2(H[1], match[1], d)) { var match$1 = Caml_primitive.caml_weak_get(bucket, i); if (match$1) { return match$1[1]; @@ -331,7 +332,7 @@ function Make(H) { }); }; var find_shadow = function (t, d, iffound, ifnotfound) { - var h = H[2](d); + var h = Caml_curry.app1(H[2], d); var index = get_index(t, h); var bucket = t[1][index]; var hashes = t[2][index]; @@ -345,8 +346,8 @@ function Make(H) { else if (h === hashes[i]) { var match = Caml_primitive.caml_weak_get_copy(bucket, i); if (match) { - if (H[1](match[1], d)) { - return iffound(bucket, i); + if (Caml_curry.app2(H[1], match[1], d)) { + return Caml_curry.app2(iffound, bucket, i); } else { _i = i + 1; @@ -372,7 +373,7 @@ function Make(H) { }, /* false */0); }; var find_all = function (t, d) { - var h = H[2](d); + var h = Caml_curry.app1(H[2], d); var index = get_index(t, h); var bucket = t[1][index]; var hashes = t[2][index]; @@ -388,7 +389,7 @@ function Make(H) { else if (h === hashes[i]) { var match = Caml_primitive.caml_weak_get_copy(bucket, i); if (match) { - if (H[1](match[1], d)) { + if (Caml_curry.app2(H[1], match[1], d)) { var match$1 = Caml_primitive.caml_weak_get(bucket, i); if (match$1) { _accu = [ diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 61ce36c142..d09a86ead0 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -136,6 +136,8 @@ of_string_test.cmo : mt.cmo of_string_test.cmx : mt.cmx primitive_reg_test.cmo : primitive_reg_test.cmx : +printf_test.cmo : ../stdlib/printf.cmi mt.cmo +printf_test.cmx : ../stdlib/printf.cmx mt.cmx qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \ ../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \ ../stdlib/array.cmi @@ -494,6 +496,8 @@ of_string_test.cmo : mt.cmo of_string_test.cmj : mt.cmj primitive_reg_test.cmo : primitive_reg_test.cmj : +printf_test.cmo : ../stdlib/printf.cmi mt.cmo +printf_test.cmj : ../stdlib/printf.cmj mt.cmj qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \ ../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \ ../stdlib/array.cmi diff --git a/jscomp/test/a_recursive_type.js b/jscomp/test/a_recursive_type.js index 9a72b68dd4..3939a85f45 100644 --- a/jscomp/test/a_recursive_type.js +++ b/jscomp/test/a_recursive_type.js @@ -1,9 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); function g(x) { - return x[1](x); + return Caml_curry.app1(x[1], x); } var loop = g([ diff --git a/jscomp/test/ari_regress_test.js b/jscomp/test/ari_regress_test.js index 1994fc7bdf..dc4bceb884 100644 --- a/jscomp/test/ari_regress_test.js +++ b/jscomp/test/ari_regress_test.js @@ -1,7 +1,8 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Mt = require("./mt"); +var Mt = require("./mt"); +var Caml_curry = require("../runtime/caml_curry"); var g = 7; @@ -46,7 +47,7 @@ var suites_002 = [ return [ /* Eq */0, 14, - v(1) + Caml_curry.app1(v, 1) ]; } ], diff --git a/jscomp/test/arith_lexer.js b/jscomp/test/arith_lexer.js index 436a816d0e..175f9b1fa9 100644 --- a/jscomp/test/arith_lexer.js +++ b/jscomp/test/arith_lexer.js @@ -4,6 +4,7 @@ var Pervasives = require("../stdlib/pervasives"); 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, @@ -29,7 +30,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) { - lexbuf[1](lexbuf); + Caml_curry.app1(lexbuf[1], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; } else { diff --git a/jscomp/test/array_test.js b/jscomp/test/array_test.js index c9f4f12c3f..58e0b1490a 100644 --- a/jscomp/test/array_test.js +++ b/jscomp/test/array_test.js @@ -5,6 +5,7 @@ var Mt = require("./mt"); 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"); var List = require("../stdlib/list"); function is_sorted(x) { @@ -95,7 +96,7 @@ var array_suites_002 = [ 4, 5 ], - $$Array.concat([ + Caml_curry.app1($$Array.concat, [ /* :: */0, /* array */[ 0, diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 91775ef4f0..117e6d4e67 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -4,6 +4,7 @@ var Mt = require("./mt"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); function test() { var v = [ @@ -18,13 +19,13 @@ function test() { _acc = (function(n,acc){ return function () { v[1] += n; - return acc(/* () */0); + return Caml_curry.app1(acc, /* () */0); } }(n,acc)); _n = n - 1; } else { - return acc(/* () */0); + return Caml_curry.app1(acc, /* () */0); } }; }; @@ -51,7 +52,7 @@ function test_closure() { }(i)); } $$Array.iter(function (i) { - v[1] += i(0); + v[1] += Caml_curry.app1(i, 0); return /* () */0; }, arr); return v[1]; @@ -75,7 +76,7 @@ function test_closure2() { }(j)); } $$Array.iter(function (i) { - v[1] += i(0); + v[1] += Caml_curry.app1(i, 0); return /* () */0; }, arr); return v[1]; diff --git a/jscomp/test/demo.js b/jscomp/test/demo.js index ea3fc01fa9..a8ef3369d1 100644 --- a/jscomp/test/demo.js +++ b/jscomp/test/demo.js @@ -1,9 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var BUI = require("@blp/ui"); -var UI = require("@ui"); -var Runtime = require("@runtime"); +var BUI = require("@blp/ui"); +var UI = require("@ui"); +var Runtime = require("@runtime"); +var Caml_curry = require("../runtime/caml_curry"); var data = /* array */[ [ @@ -24,12 +25,12 @@ var data = /* array */[ ]; function ui_layout(compile, lookup, appContext) { - var init = compile("bid - ask"); + var init = Caml_curry.app1(compile, "bid - ask"); var computeFunction = [ 0, function (env) { - return init(function (key) { - return lookup(env, key); + return Caml_curry.app1(init, function (key) { + return Caml_curry.app2(lookup, env, key); }); } ]; @@ -47,9 +48,9 @@ function ui_layout(compile, lookup, appContext) { stackPanel.orientation = "vertical"; stackPanel.minHeight = 10000; stackPanel.minWidth = 4000; - stackPanel.addChild(grid); - stackPanel.addChild(inputCode); - stackPanel.addChild(button); + Caml_curry.app1(stackPanel.addChild, grid); + Caml_curry.app1(stackPanel.addChild, inputCode); + Caml_curry.app1(stackPanel.addChild, button); var u = { "width": 200 }; @@ -86,12 +87,12 @@ function ui_layout(compile, lookup, appContext) { inputCode.minHeight = 100; button.text = "update formula"; button.minHeight = 20; - button.on("click", function () { + Caml_curry.app2(button.on, "click", function () { try { - var hot_function = compile(inputCode.text); + var hot_function = Caml_curry.app1(compile, inputCode.text); computeFunction[1] = function (env) { - return hot_function(function (key) { - return lookup(env, key); + return Caml_curry.app1(hot_function, function (key) { + return Caml_curry.app2(lookup, env, key); }); }; return /* () */0; @@ -100,18 +101,18 @@ function ui_layout(compile, lookup, appContext) { return /* () */0; } }); - Runtime.setInterval(function () { - return grid.dataSource = Array.prototype.map.call(data, function (param) { + Caml_curry.app2(Runtime.setInterval, function () { + return grid.dataSource = Caml_curry.app2(Array.prototype.map.call, data, function (param) { var price = param[2]; - var bid = price + 20 * Math.random(); - var ask = price + 20 * Math.random(); - var result = computeFunction[1]({ + var bid = price + 20 * Caml_curry.app0(Math.random); + var ask = price + 20 * Caml_curry.app0(Math.random); + var result = Caml_curry.app1(computeFunction[1], { "bid": bid, "ask": ask }); - var text = bid.toFixed(2); - var text$1 = ask.toFixed(2); - var text$2 = result.toFixed(2); + var text = Caml_curry.app1(bid.toFixed, 2); + var text$1 = Caml_curry.app1(ask.toFixed, 2); + var text$2 = Caml_curry.app1(result.toFixed, 2); return /* array */[ { "label": { diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index c130b3a209..e2a0f04fca 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -1,8 +1,9 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var React = require("react"); -var ReactDom = require("react-dom"); +var React = require("react"); +var Caml_curry = require("../runtime/caml_curry"); +var ReactDom = require("react-dom"); function fib(n) { if (n === 2 || n === 1) { @@ -25,7 +26,7 @@ function map(f, param) { if (param) { return [ /* Cons */0, - f(param[1]), + Caml_curry.app1(f, param[1]), map(f, param[2]) ]; } @@ -42,13 +43,13 @@ function f(param) { return 32 + param; } -ReactDom.render(React.createClass({ +Caml_curry.app2(ReactDom.render, Caml_curry.app1(React.createClass, { "render": function () { - return React.DOM.div({ + return Caml_curry.app3(React.DOM.div, { "alt": "pic" - }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!")); + }, Caml_curry.app2(React.DOM.h1, null, "hello react"), Caml_curry.app2(React.DOM.h2, null, "type safe!")); } - }), document.getElementById("hi")); + }), Caml_curry.app1(document.getElementById, "hi")); exports.fib = fib; exports.sum = sum; diff --git a/jscomp/test/ext_filename.js b/jscomp/test/ext_filename.js index 53df30b074..88e1c15e08 100644 --- a/jscomp/test/ext_filename.js +++ b/jscomp/test/ext_filename.js @@ -6,6 +6,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); var Pervasives = require("../stdlib/pervasives"); var Ext_string = require("./ext_string"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); var $$String = require("../stdlib/string"); var List = require("../stdlib/list"); @@ -16,12 +17,12 @@ var node_parent = ".."; var node_current = "."; function absolute_path(s) { - var s$1 = Filename.is_relative(s) ? Filename.concat(Caml_primitive.caml_sys_getcwd(/* () */0), s) : s; + var s$1 = Caml_curry.app1(Filename.is_relative, s) ? Filename.concat(Caml_primitive.caml_sys_getcwd(/* () */0), s) : s; var aux = function (_s) { while(true) { var s = _s; - var base = Filename.basename(s); - var dir = Filename.dirname(s); + var base = Caml_curry.app1(Filename.basename, s); + var dir = Caml_curry.app1(Filename.dirname, s); if (dir === s) { return dir; } @@ -29,7 +30,7 @@ function absolute_path(s) { _s = dir; } else if (base === Filename.parent_dir_name) { - return Filename.dirname(aux(dir)); + return Caml_curry.app1(Filename.dirname, aux(dir)); } else { return Filename.concat(aux(dir), base); @@ -64,8 +65,8 @@ function try_chop_extension(s) { } function relative_path(file1, file2) { - var dir1 = Ext_string.split(/* None */0, Filename.dirname(file1), Filename.dir_sep.charCodeAt(0)); - var dir2 = Ext_string.split(/* None */0, Filename.dirname(file2), Filename.dir_sep.charCodeAt(0)); + var dir1 = Ext_string.split(/* None */0, Caml_curry.app1(Filename.dirname, file1), Filename.dir_sep.charCodeAt(0)); + var dir2 = Ext_string.split(/* None */0, Caml_curry.app1(Filename.dirname, file2), Filename.dir_sep.charCodeAt(0)); var go = function (_dir1, _dir2) { while(true) { var dir2 = _dir2; @@ -119,7 +120,7 @@ function relative_path(file1, file2) { } function node_relative_path(path1, path2) { - return relative_path(try_chop_extension(absolute_path(path2)), try_chop_extension(absolute_path(path1))) + (node_sep + try_chop_extension(Filename.basename(path2))); + return relative_path(try_chop_extension(absolute_path(path2)), try_chop_extension(absolute_path(path1))) + (node_sep + try_chop_extension(Caml_curry.app1(Filename.basename, path2))); } exports.node_sep = node_sep; diff --git a/jscomp/test/ext_list.js b/jscomp/test/ext_list.js index ab26a129c6..5d8a62c005 100644 --- a/jscomp/test/ext_list.js +++ b/jscomp/test/ext_list.js @@ -3,6 +3,7 @@ var Pervasives = require("../stdlib/pervasives"); var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); function filter_map(f, _xs) { @@ -10,7 +11,7 @@ function filter_map(f, _xs) { var xs = _xs; if (xs) { var ys = xs[2]; - var match = f(xs[1]); + var match = Caml_curry.app1(f, xs[1]); if (match) { return [ /* :: */0, @@ -57,7 +58,7 @@ function filter_mapi(f, xs) { var i = _i; if (xs) { var ys = xs[2]; - var match = f(i, xs[1]); + var match = Caml_curry.app2(f, i, xs[1]); if (match) { return [ /* :: */0, @@ -86,7 +87,7 @@ function filter_map2(f, _xs, _ys) { if (ys) { var vs = ys[2]; var us = xs[2]; - var match = f(xs[1], ys[1]); + var match = Caml_curry.app2(f, xs[1], ys[1]); if (match) { return [ /* :: */0, @@ -122,7 +123,7 @@ function filter_map2i(f, xs, ys) { if (ys) { var vs = ys[2]; var us = xs[2]; - var match = f(i, xs[1], ys[1]); + var match = Caml_curry.app3(f, i, xs[1], ys[1]); if (match) { return [ /* :: */0, @@ -158,7 +159,7 @@ function rev_map_append(f, _l1, _l2) { if (l1) { _l2 = [ /* :: */0, - f(l1[1]), + Caml_curry.app1(f, l1[1]), l2 ]; _l1 = l1[2]; @@ -181,7 +182,7 @@ function flat_map2(f, lx, ly) { if (ly$1) { _ly = ly$1[2]; _lx = lx$1[2]; - _acc = List.rev_append(f(lx$1[1], ly$1[1]), acc); + _acc = List.rev_append(Caml_curry.app2(f, lx$1[1], ly$1[1]), acc); } else { return Pervasives.invalid_arg("Ext_list.flat_map2"); @@ -204,7 +205,7 @@ function flat_map(f, lx) { var acc = _acc; if (lx$1) { _lx = lx$1[2]; - _acc = List.rev_append(f(lx$1[1]), acc); + _acc = List.rev_append(Caml_curry.app1(f, lx$1[1]), acc); } else { return List.rev(acc); @@ -227,7 +228,7 @@ function map2_last(f, l1, l2) { else { return [ /* :: */0, - f(/* true */1, u, l2[1]), + Caml_curry.app3(f, /* true */1, u, l2[1]), /* [] */0 ]; } @@ -237,7 +238,7 @@ function map2_last(f, l1, l2) { } if (exit === 1) { if (l2) { - var r = f(/* false */0, u, l2[1]); + var r = Caml_curry.app3(f, /* false */0, u, l2[1]); return [ /* :: */0, r, @@ -263,7 +264,7 @@ function map_last(f, l1) { var l1$1 = l1[2]; var u = l1[1]; if (l1$1) { - var r = f(/* false */0, u); + var r = Caml_curry.app2(f, /* false */0, u); return [ /* :: */0, r, @@ -273,7 +274,7 @@ function map_last(f, l1) { else { return [ /* :: */0, - f(/* true */1, u), + Caml_curry.app2(f, /* true */1, u), /* [] */0 ]; } @@ -345,7 +346,7 @@ function aux(cmp, x, xss) { if (xss) { var ys = xss[2]; var y = xss[1]; - if (cmp(x, List.hd(y))) { + if (Caml_curry.app2(cmp, x, List.hd(y))) { return [ /* :: */0, [ @@ -408,7 +409,7 @@ function for_all_ret(p, _param) { var param = _param; if (param) { var a = param[1]; - if (p(a)) { + if (Caml_curry.app1(p, a)) { _param = param[2]; } else { @@ -428,7 +429,7 @@ function for_all_opt(p, _param) { while(true) { var param = _param; if (param) { - var v = p(param[1]); + var v = Caml_curry.app1(p, param[1]); if (v) { return v; } @@ -444,7 +445,7 @@ function for_all_opt(p, _param) { function fold(f, l, init) { return List.fold_left(function (_, i) { - return f(i, init); + return Caml_curry.app2(f, i, init); }, init, l); } @@ -458,7 +459,7 @@ function rev_map_acc(acc, f, l) { _param = param[2]; _accu = [ /* :: */0, - f(param[1]), + Caml_curry.app1(f, param[1]), accu ]; } @@ -471,7 +472,7 @@ function rev_map_acc(acc, f, l) { function rev_iter(f, xs) { if (xs) { rev_iter(f, xs[2]); - return f(xs[1]); + return Caml_curry.app1(f, xs[1]); } else { return /* () */0; diff --git a/jscomp/test/ext_string.js b/jscomp/test/ext_string.js index 551c5e4c66..244c8f5a77 100644 --- a/jscomp/test/ext_string.js +++ b/jscomp/test/ext_string.js @@ -4,6 +4,7 @@ var Bytes = require("../stdlib/bytes"); var Ext_bytes = require("./ext_bytes"); var $$String = require("../stdlib/string"); +var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); function split_by($staropt$star, is_delim, str) { @@ -23,7 +24,7 @@ function split_by($staropt$star, is_delim, str) { acc ]; } - else if (is_delim(str.charCodeAt(pos))) { + else if (Caml_curry.app1(is_delim, str.charCodeAt(pos))) { var new_len = last_pos - pos - 1; if (new_len !== 0 || keep_empty) { var v = $$String.sub(str, pos + 1, new_len); @@ -131,7 +132,7 @@ function escaped(s) { }; }; if (needs_escape(0)) { - return Bytes.unsafe_to_string(Ext_bytes.escaped(Bytes.unsafe_of_string(s))); + return Caml_curry.app1(Bytes.unsafe_to_string, Ext_bytes.escaped(Caml_curry.app1(Bytes.unsafe_of_string, s))); } else { return s; @@ -146,7 +147,7 @@ function for_all(p, s) { if (i >= len) { return /* true */1; } - else if (p(s.charCodeAt(i))) { + else if (Caml_curry.app1(p, s.charCodeAt(i))) { _i = i + 1; } else { diff --git a/jscomp/test/for_loop_test.js b/jscomp/test/for_loop_test.js index 3a66c614bd..e821b0a5d6 100644 --- a/jscomp/test/for_loop_test.js +++ b/jscomp/test/for_loop_test.js @@ -3,6 +3,7 @@ var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); function for_3(x) { @@ -23,7 +24,7 @@ function for_3(x) { }(j)); } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return v[1]; } @@ -47,7 +48,7 @@ function for_4(x) { }(k)); } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return v[1]; } @@ -70,7 +71,7 @@ function for_5(x, u) { }(k)); } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return v[1]; } @@ -115,7 +116,7 @@ function for_6(x, u) { inspect_3 = v2[1]; } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return /* array */[ v[1], @@ -148,7 +149,7 @@ function for_7() { }(i)); } $$Array.iter(function (f) { - return f(/* () */0); + return Caml_curry.app1(f, /* () */0); }, arr); return v[1]; } @@ -178,7 +179,7 @@ function for_8() { }(i,k)); } $$Array.iter(function (f) { - return f(/* () */0); + return Caml_curry.app1(f, /* () */0); }, arr); return v[1]; } @@ -225,7 +226,7 @@ function for_9() { (function(v$1){ for(var j = 0 ,j_finish = j_len - 1; j<= j_finish; ++j){ ++ v$1[1]; - collect(v$1[1]); + Caml_curry.app1(collect, v$1[1]); arr[i * j_len + j] = function () { vv[1] += v$1[1]; return /* () */0; @@ -240,15 +241,15 @@ function for_9() { }(v$1)); } $$Array.iter(function (f) { - return f(/* () */0); + return Caml_curry.app1(f, /* () */0); }, arr); $$Array.iter(function (f) { - return f(/* () */0); + return Caml_curry.app1(f, /* () */0); }, arr2); return /* array */[[ /* tuple */0, vv[1], - match_002(/* () */0), + Caml_curry.app1(match_002, /* () */0), vv2[1] ]]; } diff --git a/jscomp/test/inline_regression_test.js b/jscomp/test/inline_regression_test.js index 74f813028a..30b66ce4eb 100644 --- a/jscomp/test/inline_regression_test.js +++ b/jscomp/test/inline_regression_test.js @@ -1,9 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Filename = require("../stdlib/filename"); -var Mt = require("./mt"); -var $$String = require("../stdlib/string"); +var Filename = require("../stdlib/filename"); +var Mt = require("./mt"); +var $$String = require("../stdlib/string"); +var Caml_curry = require("../runtime/caml_curry"); function generic_basename(is_dir_sep, current_dir_name, name) { if (name === "") { @@ -16,7 +17,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - else if (is_dir_sep(name, n)) { + else if (Caml_curry.app2(is_dir_sep, name, n)) { _n = n - 1; } else { @@ -27,7 +28,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n$1 < 0) { return $$String.sub(name, 0, p); } - else if (is_dir_sep(name, n$1)) { + else if (Caml_curry.app2(is_dir_sep, name, n$1)) { return $$String.sub(name, n$1 + 1, p - n$1 - 1); } else { diff --git a/jscomp/test/int_map.js b/jscomp/test/int_map.js index aeb7195175..ba94c25891 100644 --- a/jscomp/test/int_map.js +++ b/jscomp/test/int_map.js @@ -4,6 +4,7 @@ var Pervasives = require("../stdlib/pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); function height(param) { if (param) { @@ -277,7 +278,7 @@ function iter(f, _param) { var param = _param; if (param) { iter(f, param[1]); - f(param[2], param[3]); + Caml_curry.app2(f, param[2], param[3]); _param = param[4]; } else { @@ -289,7 +290,7 @@ function iter(f, _param) { function map(f, param) { if (param) { var l$prime = map(f, param[1]); - var d$prime = f(param[3]); + var d$prime = Caml_curry.app1(f, param[3]); var r$prime = map(f, param[4]); return [ /* Node */0, @@ -309,7 +310,7 @@ function mapi(f, param) { if (param) { var v = param[2]; var l$prime = mapi(f, param[1]); - var d$prime = f(v, param[3]); + var d$prime = Caml_curry.app2(f, v, param[3]); var r$prime = mapi(f, param[4]); return [ /* Node */0, @@ -330,7 +331,7 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; } else { @@ -343,7 +344,7 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; } @@ -365,7 +366,7 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { return /* true */1; } else if (exists(p, param[1])) { @@ -502,7 +503,7 @@ function merge(f, s1, s2) { var v1 = s1[2]; if (s1[5] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, f(v1, [ + 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])); @@ -521,7 +522,7 @@ function merge(f, s1, s2) { if (s2) { var v2 = s2[2]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, f(v2, match$1[2], [ + 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])); @@ -547,7 +548,7 @@ function filter(p, param) { var d = param[3]; var v = param[2]; var l$prime = filter(p, param[1]); - var pvd = p(v, d); + var pvd = Caml_curry.app2(p, v, d); var r$prime = filter(p, param[4]); if (pvd) { return join(l$prime, v, d, r$prime); @@ -568,7 +569,7 @@ function partition(p, param) { var match = partition(p, param[1]); var lf = match[2]; var lt = match[1]; - var pvd = p(v, d); + 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]; @@ -629,7 +630,7 @@ function compare(cmp, m1, m2) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -661,7 +662,7 @@ function equal(cmp, m1, m2) { if (e1) { if (e2) { if (e1[1] === e2[1]) { - if (cmp(e1[2], e2[2])) { + if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); } diff --git a/jscomp/test/lexer_test.js b/jscomp/test/lexer_test.js index ea64648f0e..4070140785 100644 --- a/jscomp/test/lexer_test.js +++ b/jscomp/test/lexer_test.js @@ -7,6 +7,7 @@ var Mt = require("./mt"); var Lexing = require("../stdlib/lexing"); var Number_lexer = require("./number_lexer"); var Arith_lexer = require("./arith_lexer"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); var Arith_parser = require("./arith_parser"); @@ -15,7 +16,7 @@ function get_tokens(lex, str) { var _acc = /* [] */0; while(true) { var acc = _acc; - var v = lex(buf); + var v = Caml_curry.app1(lex, buf); if (v === /* EOF */7) { return List.rev(acc); } diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index 6684435ed8..b29ecbf384 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -7,6 +7,7 @@ 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 Caml_curry = require("../runtime/caml_curry"); var $$String = require("../stdlib/string"); var List = require("../stdlib/list"); var Test_inline_map = require("./test_inline_map"); @@ -159,7 +160,7 @@ function compare(cmp, m1, m2) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -191,7 +192,7 @@ function equal(cmp, m1, m2) { if (e1) { if (e2) { if (e1[1] === e2[1]) { - if (cmp(e1[2], e2[2])) { + if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); } diff --git a/jscomp/test/mt.js b/jscomp/test/mt.js index bbe07a5fe7..d2ab4992b4 100644 --- a/jscomp/test/mt.js +++ b/jscomp/test/mt.js @@ -1,36 +1,37 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Assert = require("assert"); -var List = require("../stdlib/list"); +var Assert = require("assert"); +var Caml_curry = require("../runtime/caml_curry"); +var List = require("../stdlib/list"); function assert_equal(prim, prim$1) { - return Assert.deepEqual(prim, prim$1); + return Caml_curry.app2(Assert.deepEqual, prim, prim$1); } function assert_notequal(prim, prim$1) { - return Assert.notDeepEqual(prim, prim$1); + return Caml_curry.app2(Assert.notDeepEqual, prim, prim$1); } function from_suites(name, suite) { - return describe(name, function () { + return Caml_curry.app2(describe, name, function () { return List.iter(function (param) { - return it(param[1], param[2]); + return Caml_curry.app2(it, param[1], param[2]); }, suite); }); } function from_pair_suites(name, suites) { - return describe(name, function () { + return Caml_curry.app2(describe, name, function () { return List.iter(function (param) { var code = param[2]; - return it(param[1], function () { - var match = code(/* () */0); + return Caml_curry.app2(it, param[1], function () { + var match = Caml_curry.app1(code, /* () */0); if (match[0]) { - return Assert.notDeepEqual(match[1], match[2]); + return Caml_curry.app2(Assert.notDeepEqual, match[1], match[2]); } else { - return Assert.deepEqual(match[1], match[2]); + return Caml_curry.app2(Assert.deepEqual, match[1], match[2]); } }); }, suites); diff --git a/jscomp/test/number_lexer.js b/jscomp/test/number_lexer.js index 4872a9652c..602887a3aa 100644 --- a/jscomp/test/number_lexer.js +++ b/jscomp/test/number_lexer.js @@ -4,9 +4,10 @@ var Pervasives = require("../stdlib/pervasives"); var Lexing = require("../stdlib/lexing"); var Sys = require("../stdlib/sys"); +var Caml_curry = require("../runtime/caml_curry"); var l = Sys.is_js ? function (prim) { - return console.log(prim); + return Caml_curry.app1(console.log, prim); } : function (param) { return Pervasives.output_string(Pervasives.stdout, param); }; @@ -35,51 +36,51 @@ 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) { - lexbuf[1](lexbuf); + Caml_curry.app1(lexbuf[1], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; } else { switch (__ocaml_lex_state$1) { case 0 : - l("new line"); + Caml_curry.app1(l, "new line"); ___ocaml_lex_state = 0; break; case 1 : - l("number"); - l(Lexing.lexeme(lexbuf)); + Caml_curry.app1(l, "number"); + Caml_curry.app1(l, Lexing.lexeme(lexbuf)); ___ocaml_lex_state = 0; break; case 2 : - l("ident"); - l(Lexing.lexeme(lexbuf)); + Caml_curry.app1(l, "ident"); + Caml_curry.app1(l, Lexing.lexeme(lexbuf)); ___ocaml_lex_state = 0; break; case 3 : - l("+"); + Caml_curry.app1(l, "+"); ___ocaml_lex_state = 0; break; case 4 : - l("-"); + Caml_curry.app1(l, "-"); ___ocaml_lex_state = 0; break; case 5 : - l("*"); + Caml_curry.app1(l, "*"); ___ocaml_lex_state = 0; break; case 6 : - l("/"); + Caml_curry.app1(l, "/"); ___ocaml_lex_state = 0; break; case 7 : - l("("); + Caml_curry.app1(l, "("); ___ocaml_lex_state = 0; break; case 8 : - l(")"); + Caml_curry.app1(l, ")"); ___ocaml_lex_state = 0; break; case 9 : - return l("eof"); + return Caml_curry.app1(l, "eof"); } } diff --git a/jscomp/test/obj_test.js b/jscomp/test/obj_test.js index bb7ba80fac..9c09cef345 100644 --- a/jscomp/test/obj_test.js +++ b/jscomp/test/obj_test.js @@ -4,6 +4,7 @@ var Caml_oo = require("../runtime/caml_oo"); var Mt = require("./mt"); var CamlinternalOO = require("../stdlib/camlinternalOO"); +var Caml_curry = require("../runtime/caml_curry"); var shared = [ 0, @@ -32,7 +33,7 @@ CamlinternalOO.set_methods($$class, /* array */[ }, hello, function (self$neg1, z) { - return self$neg1[1][hi](self$neg1, 10, z); + return Caml_curry.app3(self$neg1[1][hi], self$neg1, 10, z); } ]); @@ -163,7 +164,7 @@ CamlinternalOO.set_methods($$class$5, /* array */[ }, hi$2, function (self$neg6, x) { - return self$neg6[1][add$1](self$neg6, x, 32); + return Caml_curry.app3(self$neg6[1][add$1], self$neg6, x, 32); } ]); @@ -182,8 +183,8 @@ var suites_001 = [ 32 ], /* array */[ - Caml_oo.caml_get_public_method(v, 120, 1)(v), - Caml_oo.caml_get_public_method(v, 121, 2)(v) + 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) ] ]; } @@ -202,8 +203,8 @@ var suites_002 = [ 32 ], /* array */[ - Caml_oo.caml_get_public_method(v, 120, 3)(v), - Caml_oo.caml_get_public_method(v, 121, 4)(v) + 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) ] ]; } @@ -217,7 +218,7 @@ var suites_002 = [ return [ /* Eq */0, 13, - Caml_oo.caml_get_public_method(vv, 616641298, 5)(vv, 3) + Caml_curry.app2(Caml_oo.caml_get_public_method(vv, 616641298, 5), vv, 3) ]; } ], @@ -230,7 +231,7 @@ var suites_002 = [ return [ /* Eq */0, "uu", - Caml_oo.caml_get_public_method(uu, 23515, 6)(uu) + Caml_curry.app1(Caml_oo.caml_get_public_method(uu, 23515, 6), uu) ]; } ], @@ -242,7 +243,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(uuu, 4846113, 7)(uuu, 1, 20), + Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 7), uuu, 1, 20), 21 ]; } @@ -255,7 +256,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(vvvv, 4846113, 8)(vvvv, 3, 7), + Caml_curry.app3(Caml_oo.caml_get_public_method(vvvv, 4846113, 8), vvvv, 3, 7), 10 ]; } @@ -268,7 +269,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(u, 5243894, 9)(u), + Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243894, 9), u), 3 ]; } @@ -281,7 +282,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(u, 5243895, 10)(u), + Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243895, 10), u), 4 ]; } @@ -294,7 +295,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(u, 23297, 11)(u, 1, 2), + Caml_curry.app3(Caml_oo.caml_get_public_method(u, 23297, 11), u, 1, 2), 3 ]; } @@ -307,7 +308,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(u, 616641298, 12)(u, 32), + Caml_curry.app2(Caml_oo.caml_get_public_method(u, 616641298, 12), u, 32), 32 ]; } @@ -320,7 +321,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(vvvv, 23297, 13)(vvvv, 31), + Caml_curry.app2(Caml_oo.caml_get_public_method(vvvv, 23297, 13), vvvv, 31), 63 ]; } @@ -333,7 +334,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(uuu, 4846113, 14)(uuu, 3, 4), + Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 14), uuu, 3, 4), 7 ]; } @@ -346,7 +347,7 @@ var suites_002 = [ function () { return [ /* Eq */0, - Caml_oo.caml_get_public_method(v, 120, 15)(v), + Caml_curry.app1(Caml_oo.caml_get_public_method(v, 120, 15), v), 3 ]; } diff --git a/jscomp/test/printf_test.d.ts b/jscomp/test/printf_test.d.ts new file mode 100644 index 0000000000..cab0dc909f --- /dev/null +++ b/jscomp/test/printf_test.d.ts @@ -0,0 +1,2 @@ +export var suites: any ; + diff --git a/jscomp/test/printf_test.js b/jscomp/test/printf_test.js new file mode 100644 index 0000000000..1d0a4d6c74 --- /dev/null +++ b/jscomp/test/printf_test.js @@ -0,0 +1,43 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Mt = require("./mt"); +var Printf = require("../stdlib/printf"); +var Caml_curry = require("../runtime/caml_curry"); + +var suites_001 = [ + /* tuple */0, + "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) + ]; + } +]; + +var suites = [ + /* :: */0, + suites_001, + /* [] */0 +]; + +Mt.from_pair_suites("printf_test.ml", suites); + +exports.suites = suites; +/* Not a pure module */ diff --git a/jscomp/test/printf_test.ml b/jscomp/test/printf_test.ml new file mode 100644 index 0000000000..8220480a82 --- /dev/null +++ b/jscomp/test/printf_test.ml @@ -0,0 +1,9 @@ + + + +let suites = Mt.[ + "sprintf_simple", (fun _ -> Eq("3232", Printf.sprintf "%s%d" "32" 32)) + ] + + +;; Mt.from_pair_suites __FILE__ suites diff --git a/jscomp/test/qcc.js b/jscomp/test/qcc.js index 1cf1686dd9..f907e0b4bf 100644 --- a/jscomp/test/qcc.js +++ b/jscomp/test/qcc.js @@ -9,6 +9,7 @@ var Sys = require("../stdlib/sys"); var Printf = require("../stdlib/printf"); var Caml_primitive = require("../runtime/caml_primitive"); var Caml_array = require("../runtime/caml_array"); +var Caml_curry = require("../runtime/caml_curry"); var $$String = require("../stdlib/string"); var List = require("../stdlib/list"); @@ -36,7 +37,7 @@ function bufferize(f) { return match[1]; } else { - return f(/* () */0); + return Caml_curry.app1(f, /* () */0); } }, function (x) { @@ -62,7 +63,7 @@ function bufferize(f) { } var match = bufferize(function () { - return Pervasives.input_char(inch[1]); + return Caml_curry.app1(Pervasives.input_char, inch[1]); }); var ungetch = match[2]; @@ -70,8 +71,8 @@ var ungetch = match[2]; var getch = match[1]; function peekch() { - var ch = getch(/* () */0); - ungetch(ch); + var ch = Caml_curry.app1(getch, /* () */0); + Caml_curry.app1(ungetch, ch); return ch; } @@ -122,7 +123,7 @@ function match_002(n) { function match_003(f) { for(var i = 0 ,i_finish = syms[1] - 1; i<= i_finish; ++i){ - f(i, symtab[i]); + Caml_curry.app2(f, i, symtab[i]); } return /* () */0; } @@ -147,12 +148,12 @@ var textoff = 232; var s = new Array(100); function getq() { - var c = getch(/* () */0); + var c = Caml_curry.app1(getch, /* () */0); if (c !== 92 || peekch(/* () */0) !== /* "n" */110) { return c; } else { - getch(/* () */0); + Caml_curry.app1(getch, /* () */0); return /* "\n" */10; } } @@ -177,21 +178,21 @@ function isid(param) { function skip(_param) { while(true) { - var ch = getch(/* () */0); + var ch = Caml_curry.app1(getch, /* () */0); if (ch >= 14) { if (ch !== 32) { if (ch !== 47 || peekch(/* () */0) !== /* "*" */42) { return ch; } else { - var _param$1 = getch(/* () */0); + var _param$1 = Caml_curry.app1(getch, /* () */0); while(true) { - var match = getch(/* () */0); + var match = Caml_curry.app1(getch, /* () */0); if (match !== 42) { _param$1 = /* () */0; } else if (peekch(/* () */0) === /* "/" */47) { - return skip(getch(/* () */0)); + return skip(Caml_curry.app1(getch, /* () */0)); } else { _param$1 = /* () */0; @@ -256,7 +257,7 @@ function next() { ]; } else { - _n = 10 * n + getch(/* () */0) - 48; + _n = 10 * n + Caml_curry.app1(getch, /* () */0) - 48; } }; } @@ -266,7 +267,7 @@ function next() { } else { var ch = getq(/* () */0); - var qt = getch(/* () */0); + var qt = Caml_curry.app1(getch, /* () */0); if (qt !== /* "'" */39) { return Pervasives.failwith("syntax error"); } @@ -289,7 +290,7 @@ function next() { _e = e + 1; } else { - getch(/* () */0); + Caml_curry.app1(getch, /* () */0); gpos[1] = e + 8 & -8; return [ /* SLit */2, @@ -308,13 +309,13 @@ function next() { var n$1 = _n$1; s[n$1] = ch$1; if (isid(peekch(/* () */0))) { - _ch = getch(/* () */0); + _ch = Caml_curry.app1(getch, /* () */0); _n$1 = n$1 + 1; } else { return [ /* Sym */3, - addsym(Bytes.to_string(Bytes.sub(s, 0, n$1 + 1))) + Caml_curry.app1(addsym, Bytes.to_string(Bytes.sub(s, 0, n$1 + 1))) ]; } }; @@ -367,7 +368,7 @@ function next() { if (param) { var lop = param[1]; if (lop.charCodeAt(0) === ch$2 && lop.charCodeAt(1) === peekch(/* () */0)) { - getch(/* () */0); + Caml_curry.app1(getch, /* () */0); return [ /* Op */0, lop @@ -403,8 +404,8 @@ var unnext = match$1[2]; var next$1 = match$1[1]; function nextis(t) { - var nt = next$1(/* () */0); - unnext(nt); + var nt = Caml_curry.app1(next$1, /* () */0); + Caml_curry.app1(unnext, nt); return Caml_primitive.caml_equal(t, nt); } @@ -457,45 +458,45 @@ function patch(rel, loc, n) { var loc$prime = get32(loc); var x = rel ? n - (loc + 4) : n; if (dbg[1]) { - Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "patching at ", + Caml_curry.app3(Printf.eprintf([ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "patching at ", [ - /* String_literal */11, - " to ", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + " to ", [ - /* String_literal */11, - " (n=", + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + " (n=", [ - /* String_literal */11, - ")\n", - /* End_of_format */0 + /* 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); + ], + "patching at %d to %d (n=%d)\n" + ]), loc, x, n); } opos[1] = loc; le(32, x); @@ -1006,56 +1007,56 @@ var inss = [ ] ]; -var tokint_001 = addsym("int"); +var tokint_001 = Caml_curry.app1(addsym, "int"); var tokint = [ /* Sym */3, tokint_001 ]; -var tokchar_001 = addsym("char"); +var tokchar_001 = Caml_curry.app1(addsym, "char"); var tokchar = [ /* Sym */3, tokchar_001 ]; -var tokret_001 = addsym("return"); +var tokret_001 = Caml_curry.app1(addsym, "return"); var tokret = [ /* Sym */3, tokret_001 ]; -var tokif_001 = addsym("if"); +var tokif_001 = Caml_curry.app1(addsym, "if"); var tokif = [ /* Sym */3, tokif_001 ]; -var tokelse_001 = addsym("else"); +var tokelse_001 = Caml_curry.app1(addsym, "else"); var tokelse = [ /* Sym */3, tokelse_001 ]; -var tokwhile_001 = addsym("while"); +var tokwhile_001 = Caml_curry.app1(addsym, "while"); var tokwhile = [ /* Sym */3, tokwhile_001 ]; -var tokfor_001 = addsym("for"); +var tokfor_001 = Caml_curry.app1(addsym, "for"); var tokfor = [ /* Sym */3, tokfor_001 ]; -var tokbreak_001 = addsym("break"); +var tokbreak_001 = Caml_curry.app1(addsym, "break"); var tokbreak = [ /* Sym */3, @@ -1078,9 +1079,9 @@ function binary(stk, lvl) { var foldtst = function (_loc) { while(true) { var loc = _loc; - var t = next$1(/* () */0); + var t = Caml_curry.app1(next$1, /* () */0); if (t[0]) { - unnext(t); + Caml_curry.app1(unnext, t); return loc; } else if (lvlof(t[1]) === lvl) { @@ -1089,7 +1090,7 @@ function binary(stk, lvl) { _loc = loc$prime; } else { - unnext(t); + Caml_curry.app1(unnext, t); return loc; } }; @@ -1098,9 +1099,9 @@ function binary(stk, lvl) { if (lvl < 8) { var _param = /* () */0; while(true) { - var t = next$1(/* () */0); + var t = Caml_curry.app1(next$1, /* () */0); if (t[0]) { - return unnext(t); + return Caml_curry.app1(unnext, t); } else { var o = t[1]; @@ -1119,7 +1120,7 @@ function binary(stk, lvl) { _param = /* () */0; } else { - return unnext(t); + return Caml_curry.app1(unnext, t); } } }; @@ -1132,7 +1133,7 @@ function binary(stk, lvl) { } function unary(stk) { - var match = next$1(/* () */0); + var match = Caml_curry.app1(next$1, /* () */0); switch (match[0]) { case 0 : var o = match[1]; @@ -1142,13 +1143,13 @@ function unary(stk) { return patchlval(/* () */0); case "(" : expr(stk); - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); return postfix(stk); case "*" : - next$1(/* () */0); - var t = next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); + var t = Caml_curry.app1(next$1, /* () */0); var match$1 = Caml_primitive.caml_equal(t, tokint) ? ( - Caml_primitive.caml_equal(next$1(/* () */0), [ + Caml_primitive.caml_equal(Caml_curry.app1(next$1, /* () */0), [ /* Op */0, "*" ]) ? [ @@ -1168,7 +1169,7 @@ function unary(stk) { ] : Pervasives.failwith("[cast] expected") ); for(var k = 1 ,k_finish = match$1[2]; k<= k_finish; ++k){ - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); } unary(stk); return read(match$1[1]); @@ -1208,19 +1209,19 @@ function unary(stk) { ]; unary(stk); if (!List.mem_assoc(o, unops)) { - Pervasives.failwith(Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "unknown operator ", + Pervasives.failwith(Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, - /* End_of_format */0 - ] - ], - "unknown operator %s" - ])(o)); + /* String_literal */11, + "unknown operator ", + [ + /* String */2, + /* No_padding */0, + /* End_of_format */0 + ] + ], + "unknown operator %s" + ]), o)); } out(List.assoc(o, unops)); if (o === "!") { @@ -1281,9 +1282,9 @@ function unary(stk) { } function postfix(stk) { - var t = next$1(/* () */0); + var t = Caml_curry.app1(next$1, /* () */0); if (t[0]) { - return unnext(t); + return Caml_curry.app1(unnext, t); } else { var op = t[1]; @@ -1298,7 +1299,7 @@ function postfix(stk) { /* Op */0, ")" ])) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); return List.iter(pop, l); } else { @@ -1308,7 +1309,7 @@ function postfix(stk) { /* Op */0, "," ])) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); } _rl = List.tl(rl); _l = [ @@ -1362,7 +1363,7 @@ function postfix(stk) { exit = 1; break; default: - return unnext(t); + return Caml_curry.app1(unnext, t); } if (exit === 1) { patchlval(/* () */0); @@ -1430,9 +1431,9 @@ function expr(stk) { binary(stk, 10); var _param = /* () */0; while(true) { - var t = next$1(/* () */0); + var t = Caml_curry.app1(next$1, /* () */0); if (t[0]) { - return unnext(t); + return Caml_curry.app1(unnext, t); } else if (t[1] === "=") { patchlval(/* () */0); @@ -1449,7 +1450,7 @@ function expr(stk) { _param = /* () */0; } else { - return unnext(t); + return Caml_curry.app1(unnext, t); } }; } @@ -1458,7 +1459,7 @@ function decl(g, _n, _stk) { while(true) { var stk = _stk; var n = _n; - var t = next$1(/* () */0); + var t = Caml_curry.app1(next$1, /* () */0); if (Caml_primitive.caml_equal(t, tokint)) { var top = stk ? stk[1][2] : 0; var vars = (function(top){ @@ -1470,7 +1471,7 @@ function decl(g, _n, _stk) { /* Op */0, "*" ])) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); }; if (nextis([ /* Op */0, @@ -1483,7 +1484,7 @@ function decl(g, _n, _stk) { ]; } else { - var match = next$1(/* () */0); + var match = Caml_curry.app1(next$1, /* () */0); if (match[0] === 3) { var s = match[1]; var n$prime = n + 1; @@ -1517,7 +1518,7 @@ function decl(g, _n, _stk) { /* Op */0, "," ])) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); _stk = stk$prime; _n = n$prime; } @@ -1537,33 +1538,33 @@ function decl(g, _n, _stk) { } }(top)); var match = vars(0, stk); - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); if (dbg[1]) { - Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "end of decl (", + Caml_curry.app1(Printf.eprintf([ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "end of decl (", [ - /* String_literal */11, - " vars)\n", - /* End_of_format */0 + /* 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); + ], + "end of decl (%d vars)\n" + ]), n); } _stk = match[2]; _n = n + match[1]; } else { - unnext(t); + Caml_curry.app1(unnext, t); if (!g && n !== 0) { if (n * 8 >= 256) { throw [ @@ -1600,11 +1601,11 @@ var retl = [ function stmt(brk, stk) { var pexpr = function (stk) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); expr(stk); - return next$1(/* () */0); + return Caml_curry.app1(next$1, /* () */0); }; - var t = next$1(/* () */0); + var t = Caml_curry.app1(next$1, /* () */0); var exit = 0; if (Caml_primitive.caml_equal(t, tokif)) { pexpr(stk); @@ -1612,7 +1613,7 @@ function stmt(brk, stk) { stmt(brk, stk); var loc$1; if (nextis(tokelse)) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); out(233); var l = opos[1]; le(32, 0); @@ -1644,14 +1645,14 @@ function stmt(brk, stk) { ]; } else { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); if (!nextis([ /* Op */0, ";" ])) { expr(stk); } - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); var top = opos[1]; if (nextis([ /* Op */0, @@ -1663,13 +1664,13 @@ function stmt(brk, stk) { expr(stk); bl[1] = test(0, 0); } - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); out(233); var bdy = opos[1]; le(32, 0); var itr = opos[1]; expr(stk); - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); out(233); le(32, top - opos[1] - 4); match = [ @@ -1695,7 +1696,7 @@ function stmt(brk, stk) { ])) { expr(stk); } - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); out(233); var loc$3 = opos[1]; le(32, retl[1]); @@ -1703,7 +1704,7 @@ function stmt(brk, stk) { return /* () */0; } else if (Caml_primitive.caml_equal(t, tokbreak)) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); var brkl = brk[1]; var n = align[1] - brk[2]; if (n < 0) { @@ -1742,9 +1743,9 @@ function stmt(brk, stk) { } } if (exit === 1) { - unnext(t); + Caml_curry.app1(unnext, t); expr(stk); - return next$1(/* () */0); + return Caml_curry.app1(next$1, /* () */0); } } @@ -1759,7 +1760,7 @@ function block(brk, stk) { ])) { stmt(brk, stk$prime); }; - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); if (n !== 0) { out(4752324); out(n * 8); @@ -1784,7 +1785,7 @@ function top(_param) { _param = /* () */0; } else { - var match = next$1(/* () */0); + var match = Caml_curry.app1(next$1, /* () */0); if (match[0] === 3) { var f = match[1]; var g = globs[f]; @@ -1801,7 +1802,7 @@ function top(_param) { var stk = _stk; var n = _n; var regs = _regs; - var match = next$1(/* () */0); + var match = Caml_curry.app1(next$1, /* () */0); switch (match[0]) { case 0 : if (match[1] === ")") { @@ -1821,7 +1822,7 @@ function top(_param) { /* Op */0, "," ])) { - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); } var stk$prime_001 = [ /* tuple */0, @@ -1841,7 +1842,7 @@ function top(_param) { } }; }; - next$1(/* () */0); + Caml_curry.app1(next$1, /* () */0); align[1] = 0; out(85); out(4753893); @@ -1870,7 +1871,7 @@ function top(_param) { ] ] ], 1, /* [] */0); - while(Caml_primitive.caml_notequal(next$1(/* () */0), [ + while(Caml_primitive.caml_notequal(Caml_curry.app1(next$1, /* () */0), [ /* Op */0, "{" ])) { @@ -1888,23 +1889,23 @@ function top(_param) { patch(/* true */1, retl[1], opos[1]); out(51651); if (dbg[1]) { - Printf.eprintf([ - /* Format */0, - [ - /* String_literal */11, - "done with function ", + Caml_curry.app1(Printf.eprintf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "done with function ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] ] - ] - ], - "done with function %s\n" - ])(symstr(f)); + ], + "done with function %s\n" + ]), Caml_curry.app1(symstr, f)); } _param = /* () */0; } @@ -1990,7 +1991,7 @@ function elfphdr(ty, off, sz, align) { function elfgen(outf) { var entry = opos[1]; - var main = addsym("main"); + var main = Caml_curry.app1(addsym, "main"); var gmain = globs[main]; out(1217084452); out(311610844168); @@ -2007,10 +2008,10 @@ function elfgen(outf) { out(3845); var off = textoff + gpos[1]; var itr = function (f) { - return symitr(function (i, s) { + return Caml_curry.app1(symitr, function (i, s) { var g = globs[i]; if (g[2] < 0 && g[1] !== 0) { - return f(s, s.length, g[1]); + return Caml_curry.app3(f, s, s.length, g[1]); } else { return 0; @@ -2032,7 +2033,7 @@ function elfgen(outf) { return 0; } }; - symitr(patchloc); + Caml_curry.app1(symitr, patchloc); var strtab = opos[1]; ++ opos[1]; var dllen = 37; @@ -2198,90 +2199,90 @@ function main() { var ppsym = function (param) { switch (param[0]) { case 0 : - return Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Operator '", + return Caml_curry.app1(Printf.printf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "Operator '", [ - /* String_literal */11, - "'\n", - /* End_of_format */0 + /* String */2, + /* No_padding */0, + [ + /* String_literal */11, + "'\n", + /* End_of_format */0 + ] ] - ] - ], - "Operator '%s'\n" - ])(param[1]); + ], + "Operator '%s'\n" + ]), param[1]); case 1 : - return Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Int literal ", + return Caml_curry.app1(Printf.printf([ + /* Format */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "Int literal ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* 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]); + ], + "Int literal %d\n" + ]), param[1]); case 2 : - return Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Str literal ", + return Caml_curry.app1(Printf.printf([ + /* Format */0, [ - /* Caml_string */3, - /* No_padding */0, + /* String_literal */11, + "Str literal ", [ - /* Char_literal */12, - /* "\n" */10, - /* End_of_format */0 + /* Caml_string */3, + /* No_padding */0, + [ + /* Char_literal */12, + /* "\n" */10, + /* End_of_format */0 + ] ] - ] - ], - "Str literal %S\n" - ])(param[2]); + ], + "Str literal %S\n" + ]), param[2]); case 3 : var i = param[1]; - return Printf.printf([ - /* Format */0, - [ - /* String_literal */11, - "Symbol '", + return Caml_curry.app2(Printf.printf([ + /* Format */0, [ - /* String */2, - /* No_padding */0, + /* String_literal */11, + "Symbol '", [ - /* String_literal */11, - "' (", + /* String */2, + /* No_padding */0, [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "' (", [ - /* String_literal */11, - ")\n", - /* End_of_format */0 + /* Int */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, + [ + /* String_literal */11, + ")\n", + /* End_of_format */0 + ] ] ] ] - ] - ], - "Symbol '%s' (%d)\n" - ])(symstr(i), i); + ], + "Symbol '%s' (%d)\n" + ]), Caml_curry.app1(symstr, i), i); } }; @@ -2300,12 +2301,12 @@ function main() { }; var stk = /* [] */0; opos[1] = 0; - c(stk); + Caml_curry.app1(c, stk); return Pervasives.print_bytes(Bytes.sub(obuf, 0, opos[1])); case "-lex" : var _param = /* () */0; while(true) { - var tok = next$1(/* () */0); + var tok = Caml_curry.app1(next$1, /* () */0); if (tok[0]) { ppsym(tok); _param = /* () */0; diff --git a/jscomp/test/record_with_test.js b/jscomp/test/record_with_test.js index 1926e68309..c30aa5a0a5 100644 --- a/jscomp/test/record_with_test.js +++ b/jscomp/test/record_with_test.js @@ -1,7 +1,8 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Mt = require("./mt"); +var Mt = require("./mt"); +var Caml_curry = require("../runtime/caml_curry"); var v = [ /* record */0, @@ -19,7 +20,7 @@ var newrecord = v.slice(); newrecord[2] = 0; function f(g, h) { - var newrecord = g(h).slice(); + var newrecord = Caml_curry.app1(g, h).slice(); newrecord[2] = 0; return newrecord; } diff --git a/jscomp/test/simple_lexer_test.js b/jscomp/test/simple_lexer_test.js index b9bd047b47..463bd5bc0e 100644 --- a/jscomp/test/simple_lexer_test.js +++ b/jscomp/test/simple_lexer_test.js @@ -1,9 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Mt = require("./mt"); -var Lexing = require("../stdlib/lexing"); -var $$String = require("../stdlib/string"); +var Mt = require("./mt"); +var Lexing = require("../stdlib/lexing"); +var Caml_curry = require("../runtime/caml_curry"); +var $$String = require("../stdlib/string"); var __ocaml_lex_tables = [ /* record */0, @@ -29,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) { - lexbuf[1](lexbuf); + Caml_curry.app1(lexbuf[1], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; } else { diff --git a/jscomp/test/small_inline_test.js b/jscomp/test/small_inline_test.js index 5bb86a8214..6866f66713 100644 --- a/jscomp/test/small_inline_test.js +++ b/jscomp/test/small_inline_test.js @@ -1,29 +1,30 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); function $pipe$great(x, f) { - return f(x); + return Caml_curry.app1(f, x); } function hello1(y, f) { - return f(y); + return Caml_curry.app1(f, y); } function hello2(y, f) { - return f(y); + return Caml_curry.app1(f, y); } function hello3(y, f) { - return f(y); + return Caml_curry.app1(f, y); } function hello4(y, f) { - return f(y); + return Caml_curry.app1(f, y); } function hello5(y, f) { - return f(y); + return Caml_curry.app1(f, y); } function f(_x) { diff --git a/jscomp/test/test.mllib b/jscomp/test/test.mllib index 5067a58618..226c62fef9 100644 --- a/jscomp/test/test.mllib +++ b/jscomp/test/test.mllib @@ -156,4 +156,5 @@ record_with_test complex_if_test module_parameter_test regression_print -global_exception_regression_test \ No newline at end of file +global_exception_regression_test +printf_test \ No newline at end of file diff --git a/jscomp/test/test_ari.js b/jscomp/test/test_ari.js index 5c64c2e396..d2348038bc 100644 --- a/jscomp/test/test_ari.js +++ b/jscomp/test/test_ari.js @@ -1,9 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var VV = require("VV"); -var List = require("../stdlib/list"); -var U = require("U"); +var VV = require("VV"); +var Caml_curry = require("../runtime/caml_curry"); +var List = require("../stdlib/list"); +var U = require("U"); function f(x) { return function (param) { @@ -16,7 +17,7 @@ function f1(x, y) { } function f3(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f2(param) { @@ -26,10 +27,10 @@ function f2(param) { var g = 7; function ff(param) { - return U.test_primit(3, param); + return Caml_curry.app2(U.test_primit, 3, param); } -var fff = VV.test_primit2(3); +var fff = Caml_curry.app1(VV.test_primit2, 3); function length_aux(_len, _param) { while(true) { diff --git a/jscomp/test/test_array.js b/jscomp/test/test_array.js index 7cac1ba2a0..aceca70b3e 100644 --- a/jscomp/test/test_array.js +++ b/jscomp/test/test_array.js @@ -3,6 +3,7 @@ var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); var v = Caml_array.caml_make_vect(6, 5); @@ -22,7 +23,7 @@ var hhh = $$Array.append(/* array */[ 5 ]); -var u = $$Array.concat([ +var u = Caml_curry.app1($$Array.concat, [ /* :: */0, /* array */[ 1, diff --git a/jscomp/test/test_bytes.js b/jscomp/test/test_bytes.js index d4c8a1761b..e3ce4da84b 100644 --- a/jscomp/test/test_bytes.js +++ b/jscomp/test/test_bytes.js @@ -2,10 +2,11 @@ 'use strict'; var Bytes = require("../stdlib/bytes"); +var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); function f(v) { - return Bytes.unsafe_to_string(v); + return Caml_curry.app1(Bytes.unsafe_to_string, v); } function ff(v) { diff --git a/jscomp/test/test_closure.js b/jscomp/test/test_closure.js index 520af115dc..933da24fc9 100644 --- a/jscomp/test/test_closure.js +++ b/jscomp/test/test_closure.js @@ -4,6 +4,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); var v = [ 0, @@ -28,7 +29,7 @@ function f() { var u = f(/* () */0); $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, u); if (v[1] !== 45) { diff --git a/jscomp/test/test_cps.js b/jscomp/test/test_cps.js index 488656a145..59a4b4b603 100644 --- a/jscomp/test/test_cps.js +++ b/jscomp/test/test_cps.js @@ -2,6 +2,7 @@ 'use strict'; var Caml_array = require("../runtime/caml_array"); +var Caml_curry = require("../runtime/caml_curry"); function f(_n, _acc) { while(true) { @@ -11,13 +12,13 @@ function f(_n, _acc) { _acc = (function(n,acc){ return function () { console.log("" + n); - return acc(/* () */0); + return Caml_curry.app1(acc, /* () */0); } }(n,acc)); _n = n - 1; } else { - return acc(/* () */0); + return Caml_curry.app1(acc, /* () */0); } }; } diff --git a/jscomp/test/test_demo.js b/jscomp/test/test_demo.js index 745990752c..58ce15327d 100644 --- a/jscomp/test/test_demo.js +++ b/jscomp/test/test_demo.js @@ -1,7 +1,8 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var List = require("../stdlib/list"); +var Caml_curry = require("../runtime/caml_curry"); +var List = require("../stdlib/list"); function fib(n) { if (n === 2 || n === 1) { @@ -24,7 +25,7 @@ function map(f, param) { if (param) { return [ /* Cons */0, - f(param[1]), + Caml_curry.app1(f, param[1]), map(f, param[2]) ]; } diff --git a/jscomp/test/test_external.js b/jscomp/test/test_external.js index b121d3014e..22e58dbf08 100644 --- a/jscomp/test/test_external.js +++ b/jscomp/test/test_external.js @@ -1,10 +1,11 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); -var xx = document(); +var xx = Caml_curry.app0(document); -alert("hehha"); +Caml_curry.app1(alert, "hehha"); exports.xx = xx; /* xx Not a pure module */ diff --git a/jscomp/test/test_ffi.js b/jscomp/test/test_ffi.js index 5792b6ad22..64679936b6 100644 --- a/jscomp/test/test_ffi.js +++ b/jscomp/test/test_ffi.js @@ -1,9 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); function v(u) { - console.log(u); + Caml_curry.app1(console.log, u); return u; } diff --git a/jscomp/test/test_fib.js b/jscomp/test/test_fib.js index c6b5b4a5e7..5ab33ec0d2 100644 --- a/jscomp/test/test_fib.js +++ b/jscomp/test/test_fib.js @@ -1,6 +1,7 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); function fib(n) { if (n === 0 || n === 1) { @@ -57,7 +58,7 @@ function map(f, x) { if (x) { return [ /* Cons */0, - f(x[1]), + Caml_curry.app1(f, x[1]), map(f, x[2]) ]; } diff --git a/jscomp/test/test_for_loop.js b/jscomp/test/test_for_loop.js index 6e147e75f6..a1c1fda7e4 100644 --- a/jscomp/test/test_for_loop.js +++ b/jscomp/test/test_for_loop.js @@ -1,7 +1,8 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var $$Array = require("../stdlib/array"); +var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); function for_(x) { for(var i = 0 ,i_finish = (console.log("hi"), x.length); i<= i_finish; ++i){ @@ -35,7 +36,7 @@ function for_3(x) { }(j)); } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return v[1]; } @@ -59,7 +60,7 @@ function for_4(x) { }(k)); } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return v[1]; } @@ -82,7 +83,7 @@ function for_5(x, u) { }(k)); } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return v[1]; } @@ -125,7 +126,7 @@ function for_6(x, u) { }(v2)); } $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); return v[1]; } diff --git a/jscomp/test/test_for_map.js b/jscomp/test/test_for_map.js index 731f67b5b4..7588147186 100644 --- a/jscomp/test/test_for_map.js +++ b/jscomp/test/test_for_map.js @@ -4,6 +4,7 @@ var Pervasives = require("../stdlib/pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); function height(param) { if (param) { @@ -277,7 +278,7 @@ function iter(f, _param) { var param = _param; if (param) { iter(f, param[1]); - f(param[2], param[3]); + Caml_curry.app2(f, param[2], param[3]); _param = param[4]; } else { @@ -289,7 +290,7 @@ function iter(f, _param) { function map(f, param) { if (param) { var l$prime = map(f, param[1]); - var d$prime = f(param[3]); + var d$prime = Caml_curry.app1(f, param[3]); var r$prime = map(f, param[4]); return [ /* Node */0, @@ -309,7 +310,7 @@ function mapi(f, param) { if (param) { var v = param[2]; var l$prime = mapi(f, param[1]); - var d$prime = f(v, param[3]); + var d$prime = Caml_curry.app2(f, v, param[3]); var r$prime = mapi(f, param[4]); return [ /* Node */0, @@ -330,7 +331,7 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; } else { @@ -343,7 +344,7 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; } @@ -365,7 +366,7 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { return /* true */1; } else if (exists(p, param[1])) { @@ -502,7 +503,7 @@ function merge(f, s1, s2) { var v1 = s1[2]; if (s1[5] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, f(v1, [ + 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])); @@ -521,7 +522,7 @@ function merge(f, s1, s2) { if (s2) { var v2 = s2[2]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, f(v2, match$1[2], [ + 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])); @@ -547,7 +548,7 @@ function filter(p, param) { var d = param[3]; var v = param[2]; var l$prime = filter(p, param[1]); - var pvd = p(v, d); + var pvd = Caml_curry.app2(p, v, d); var r$prime = filter(p, param[4]); if (pvd) { return join(l$prime, v, d, r$prime); @@ -568,7 +569,7 @@ function partition(p, param) { var match = partition(p, param[1]); var lf = match[2]; var lt = match[1]; - var pvd = p(v, d); + 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]; @@ -629,7 +630,7 @@ function compare(cmp, m1, m2) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -661,7 +662,7 @@ function equal(cmp, m1, m2) { if (e1) { if (e2) { if (e1[1] === e2[1]) { - if (cmp(e1[2], e2[2])) { + if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); } diff --git a/jscomp/test/test_format.js b/jscomp/test/test_format.js index 9b487423f8..a91756d8d3 100644 --- a/jscomp/test/test_format.js +++ b/jscomp/test/test_format.js @@ -1,18 +1,19 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Format = require("../stdlib/format"); +var Caml_curry = require("../runtime/caml_curry"); +var Format = require("../stdlib/format"); -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 */4, + /* Int_d */0, + /* No_padding */0, + /* No_precision */0, + /* End_of_format */0 + ], + "%d" + ]), 3); /* Not a pure module */ diff --git a/jscomp/test/test_internalOO.js b/jscomp/test/test_internalOO.js index aee51d7977..b0f5146ce7 100644 --- a/jscomp/test/test_internalOO.js +++ b/jscomp/test/test_internalOO.js @@ -10,6 +10,7 @@ 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"); var Caml_string = require("../runtime/caml_string"); var List = require("../stdlib/list"); @@ -318,7 +319,7 @@ function iter(f, _param) { var param = _param; if (param) { iter(f, param[1]); - f(param[2], param[3]); + Caml_curry.app2(f, param[2], param[3]); _param = param[4]; } else { @@ -330,7 +331,7 @@ function iter(f, _param) { function map(f, param) { if (param) { var l$prime = map(f, param[1]); - var d$prime = f(param[3]); + var d$prime = Caml_curry.app1(f, param[3]); var r$prime = map(f, param[4]); return [ /* Node */0, @@ -350,7 +351,7 @@ function mapi(f, param) { if (param) { var v = param[2]; var l$prime = mapi(f, param[1]); - var d$prime = f(v, param[3]); + var d$prime = Caml_curry.app2(f, v, param[3]); var r$prime = mapi(f, param[4]); return [ /* Node */0, @@ -371,7 +372,7 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; } else { @@ -384,7 +385,7 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; } @@ -406,7 +407,7 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { return /* true */1; } else if (exists(p, param[1])) { @@ -543,7 +544,7 @@ function merge(f, s1, s2) { var v1 = s1[2]; if (s1[5] >= height(s2)) { var match = split(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, f(v1, [ + 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])); @@ -562,7 +563,7 @@ function merge(f, s1, s2) { if (s2) { var v2 = s2[2]; var match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, f(v2, match$1[2], [ + 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])); @@ -588,7 +589,7 @@ function filter(p, param) { var d = param[3]; var v = param[2]; var l$prime = filter(p, param[1]); - var pvd = p(v, d); + var pvd = Caml_curry.app2(p, v, d); var r$prime = filter(p, param[4]); if (pvd) { return join(l$prime, v, d, r$prime); @@ -609,7 +610,7 @@ function partition(p, param) { var match = partition(p, param[1]); var lf = match[2]; var lt = match[1]; - var pvd = p(v, d); + 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]; @@ -670,7 +671,7 @@ function compare(cmp, m1, m2) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -704,7 +705,7 @@ function equal(cmp, m1, m2) { if (Caml_string.caml_string_compare(e1[1], e2[1])) { return /* false */0; } - else if (cmp(e1[2], e2[2])) { + else if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); } @@ -1060,7 +1061,7 @@ function iter$1(f, _param) { var param = _param; if (param) { iter$1(f, param[1]); - f(param[2], param[3]); + Caml_curry.app2(f, param[2], param[3]); _param = param[4]; } else { @@ -1072,7 +1073,7 @@ function iter$1(f, _param) { function map$1(f, param) { if (param) { var l$prime = map$1(f, param[1]); - var d$prime = f(param[3]); + var d$prime = Caml_curry.app1(f, param[3]); var r$prime = map$1(f, param[4]); return [ /* Node */0, @@ -1092,7 +1093,7 @@ function mapi$1(f, param) { if (param) { var v = param[2]; var l$prime = mapi$1(f, param[1]); - var d$prime = f(v, param[3]); + var d$prime = Caml_curry.app2(f, v, param[3]); var r$prime = mapi$1(f, param[4]); return [ /* Node */0, @@ -1113,7 +1114,7 @@ function fold$1(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold$1(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold$1(f, m[1], accu)); _m = m[4]; } else { @@ -1126,7 +1127,7 @@ function for_all$1(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { if (for_all$1(p, param[1])) { _param = param[4]; } @@ -1148,7 +1149,7 @@ function exists$1(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { return /* true */1; } else if (exists$1(p, param[1])) { @@ -1285,7 +1286,7 @@ function merge$1(f, s1, s2) { var v1 = s1[2]; if (s1[5] >= height$1(s2)) { var match = split$1(v1, s2); - return concat_or_join$1(merge$1(f, s1[1], match[1]), v1, f(v1, [ + 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])); @@ -1304,7 +1305,7 @@ function merge$1(f, s1, s2) { if (s2) { var v2 = s2[2]; var match$1 = split$1(v2, s1); - return concat_or_join$1(merge$1(f, match$1[1], s2[1]), v2, f(v2, match$1[2], [ + 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])); @@ -1330,7 +1331,7 @@ function filter$1(p, param) { var d = param[3]; var v = param[2]; var l$prime = filter$1(p, param[1]); - var pvd = p(v, d); + var pvd = Caml_curry.app2(p, v, d); var r$prime = filter$1(p, param[4]); if (pvd) { return join$1(l$prime, v, d, r$prime); @@ -1351,7 +1352,7 @@ function partition$1(p, param) { var match = partition$1(p, param[1]); var lf = match[2]; var lt = match[1]; - var pvd = p(v, d); + 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]; @@ -1412,7 +1413,7 @@ function compare$1(cmp, m1, m2) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -1446,7 +1447,7 @@ function equal$1(cmp, m1, m2) { if (Caml_string.caml_string_compare(e1[1], e2[1])) { return /* false */0; } - else if (cmp(e1[2], e2[2])) { + 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]); } @@ -1802,7 +1803,7 @@ function iter$2(f, _param) { var param = _param; if (param) { iter$2(f, param[1]); - f(param[2], param[3]); + Caml_curry.app2(f, param[2], param[3]); _param = param[4]; } else { @@ -1814,7 +1815,7 @@ function iter$2(f, _param) { function map$2(f, param) { if (param) { var l$prime = map$2(f, param[1]); - var d$prime = f(param[3]); + var d$prime = Caml_curry.app1(f, param[3]); var r$prime = map$2(f, param[4]); return [ /* Node */0, @@ -1834,7 +1835,7 @@ function mapi$2(f, param) { if (param) { var v = param[2]; var l$prime = mapi$2(f, param[1]); - var d$prime = f(v, param[3]); + var d$prime = Caml_curry.app2(f, v, param[3]); var r$prime = mapi$2(f, param[4]); return [ /* Node */0, @@ -1855,7 +1856,7 @@ function fold$2(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold$2(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold$2(f, m[1], accu)); _m = m[4]; } else { @@ -1868,7 +1869,7 @@ function for_all$2(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { if (for_all$2(p, param[1])) { _param = param[4]; } @@ -1890,7 +1891,7 @@ function exists$2(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { return /* true */1; } else if (exists$2(p, param[1])) { @@ -2027,7 +2028,7 @@ function merge$2(f, s1, s2) { var v1 = s1[2]; if (s1[5] >= height$2(s2)) { var match = split$2(v1, s2); - return concat_or_join$2(merge$2(f, s1[1], match[1]), v1, f(v1, [ + 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])); @@ -2046,7 +2047,7 @@ function merge$2(f, s1, s2) { if (s2) { var v2 = s2[2]; var match$1 = split$2(v2, s1); - return concat_or_join$2(merge$2(f, match$1[1], s2[1]), v2, f(v2, match$1[2], [ + 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])); @@ -2072,7 +2073,7 @@ function filter$2(p, param) { var d = param[3]; var v = param[2]; var l$prime = filter$2(p, param[1]); - var pvd = p(v, d); + var pvd = Caml_curry.app2(p, v, d); var r$prime = filter$2(p, param[4]); if (pvd) { return join$2(l$prime, v, d, r$prime); @@ -2093,7 +2094,7 @@ function partition$2(p, param) { var match = partition$2(p, param[1]); var lf = match[2]; var lt = match[1]; - var pvd = p(v, d); + 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]; @@ -2154,7 +2155,7 @@ function compare$2(cmp, m1, m2) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -2186,7 +2187,7 @@ function equal$2(cmp, m1, m2) { if (e1) { if (e2) { if (e1[1] === e2[1]) { - if (cmp(e1[2], e2[2])) { + 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]); } @@ -2637,9 +2638,9 @@ function init_class(table) { function inherits(cla, vals, virt_meths, concr_meths, param, top) { var $$super = param[2]; narrow(cla, vals, virt_meths, concr_meths); - var init = top ? $$super(cla, param[4]) : $$super(cla); + var init = top ? Caml_curry.app2($$super, cla, param[4]) : Caml_curry.app1($$super, cla); widen(cla); - return $$Array.concat([ + return Caml_curry.app1($$Array.concat, [ /* :: */0, /* array */[init], [ @@ -2660,11 +2661,11 @@ function inherits(cla, vals, virt_meths, concr_meths, param, top) { function make_class(pub_meths, class_init) { var table = create_table(pub_meths); - var env_init = class_init(table); + var env_init = Caml_curry.app1(class_init, table); init_class(table); return [ /* tuple */0, - env_init(0), + Caml_curry.app1(env_init, 0), class_init, env_init, 0 @@ -2673,7 +2674,7 @@ function make_class(pub_meths, class_init) { function make_class_store(pub_meths, class_init, init_table) { var table = create_table(pub_meths); - var env_init = class_init(table); + var env_init = Caml_curry.app1(class_init, table); init_class(table); init_table[2] = class_init; init_table[1] = env_init; @@ -2718,7 +2719,7 @@ function iter_f(obj, _param) { while(true) { var param = _param; if (param) { - param[1](obj); + Caml_curry.app1(param[1], obj); _param = param[2]; } else { @@ -2839,7 +2840,7 @@ function get_env(e, n) { function get_meth(n) { return function (obj) { - return obj[1][n](obj); + return Caml_curry.app1(obj[1][n], obj); }; } @@ -2852,115 +2853,115 @@ function set_var(n) { function app_const(f, x) { return function () { - return f(x); + return Caml_curry.app1(f, x); }; } function app_var(f, n) { return function (obj) { - return f(obj[n]); + return Caml_curry.app1(f, obj[n]); }; } function app_env(f, e, n) { return function (obj) { - return f(obj[e][n]); + return Caml_curry.app1(f, obj[e][n]); }; } function app_meth(f, n) { return function (obj) { - return f(obj[1][n](obj)); + return Caml_curry.app1(f, Caml_curry.app1(obj[1][n], obj)); }; } function app_const_const(f, x, y) { return function () { - return f(x, y); + return Caml_curry.app2(f, x, y); }; } function app_const_var(f, x, n) { return function (obj) { - return f(x, obj[n]); + return Caml_curry.app2(f, x, obj[n]); }; } function app_const_meth(f, x, n) { return function (obj) { - return f(x, obj[1][n](obj)); + return Caml_curry.app2(f, x, Caml_curry.app1(obj[1][n], obj)); }; } function app_var_const(f, n, x) { return function (obj) { - return f(obj[n], x); + return Caml_curry.app2(f, obj[n], x); }; } function app_meth_const(f, n, x) { return function (obj) { - return f(obj[1][n](obj), x); + return Caml_curry.app2(f, Caml_curry.app1(obj[1][n], obj), x); }; } function app_const_env(f, x, e, n) { return function (obj) { - return f(x, obj[e][n]); + return Caml_curry.app2(f, x, obj[e][n]); }; } function app_env_const(f, e, n, x) { return function (obj) { - return f(obj[e][n], x); + return Caml_curry.app2(f, obj[e][n], x); }; } function meth_app_const(n, x) { return function (obj) { - return obj[1][n](obj, x); + return Caml_curry.app2(obj[1][n], obj, x); }; } function meth_app_var(n, m) { return function (obj) { - return obj[1][n](obj, obj[m]); + return Caml_curry.app2(obj[1][n], obj, obj[m]); }; } function meth_app_env(n, e, m) { return function (obj) { - return obj[1][n](obj, obj[e][m]); + return Caml_curry.app2(obj[1][n], obj, obj[e][m]); }; } function meth_app_meth(n, m) { return function (obj) { - return obj[1][n](obj, obj[1][m](obj)); + return Caml_curry.app2(obj[1][n], obj, Caml_curry.app1(obj[1][m], obj)); }; } function send_const(m, x, _) { return function () { - return Caml_oo.caml_get_public_method(x, m, 1)(x); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, x, m, 1), x); }; } function send_var(m, n, _) { return function (obj) { - return Caml_oo.caml_get_public_method(obj[n], m, 2)(obj[n]); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, obj[n], m, 2), obj[n]); }; } function send_env(m, e, n, _) { return function (obj) { - return Caml_oo.caml_get_public_method(obj[e][n], m, 3)(obj[e][n]); + return Caml_curry.app1(Caml_curry.app3(Caml_oo.caml_get_public_method, obj[e][n], m, 3), obj[e][n]); }; } function send_meth(m, n, _) { return function (obj) { - return Caml_oo.caml_get_public_method(obj[1][n](obj), m, 4)(obj[1][n](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)); }; } @@ -3005,13 +3006,13 @@ function method_impl(table, i, arr) { var f = next(/* () */0); var x$1 = next(/* () */0); return function () { - return f(x$1); + return Caml_curry.app1(f, x$1); }; case 6 : var f$1 = next(/* () */0); var n$3 = next(/* () */0); return function (obj) { - return f$1(obj[n$3]); + return Caml_curry.app1(f$1, obj[n$3]); }; case 7 : var f$2 = next(/* () */0); @@ -3027,7 +3028,7 @@ function method_impl(table, i, arr) { var x$2 = next(/* () */0); var y = next(/* () */0); return function () { - return f$4(x$2, y); + return Caml_curry.app2(f$4, x$2, y); }; case 10 : var f$5 = next(/* () */0); diff --git a/jscomp/test/test_js_ffi.js b/jscomp/test/test_js_ffi.js index 99c55b7578..539b07669c 100644 --- a/jscomp/test/test_js_ffi.js +++ b/jscomp/test/test_js_ffi.js @@ -1,10 +1,11 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var $$String = require("../stdlib/string"); +var Caml_curry = require("../runtime/caml_curry"); +var $$String = require("../stdlib/string"); function v() { - return t([ + return Caml_curry.app1(t, [ 0, $$String.compare ]); diff --git a/jscomp/test/test_list.js b/jscomp/test/test_list.js index 12e1537bb1..05a89f1bc4 100644 --- a/jscomp/test/test_list.js +++ b/jscomp/test/test_list.js @@ -4,6 +4,7 @@ var Pervasives = require("../stdlib/pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); function length_aux(_len, _param) { @@ -101,7 +102,7 @@ function flatten(param) { function map(f, param) { if (param) { - var r = f(param[1]); + var r = Caml_curry.app1(f, param[1]); return [ /* :: */0, r, @@ -115,7 +116,7 @@ function map(f, param) { function mapi(i, f, param) { if (param) { - var r = f(i, param[1]); + var r = Caml_curry.app2(f, i, param[1]); return [ /* :: */0, r, @@ -141,7 +142,7 @@ function rev_map(f, l) { _param = param[2]; _accu = [ /* :: */0, - f(param[1]), + Caml_curry.app1(f, param[1]), accu ]; } @@ -155,7 +156,7 @@ function iter(f, _param) { while(true) { var param = _param; if (param) { - f(param[1]); + Caml_curry.app1(f, param[1]); _param = param[2]; } else { @@ -172,7 +173,7 @@ function iteri(f, l) { var param = _param; var i = _i; if (param) { - f$1(i, param[1]); + Caml_curry.app2(f$1, i, param[1]); _param = param[2]; _i = i + 1; } @@ -188,7 +189,7 @@ function fold_left(f, _accu, _l) { var accu = _accu; if (l) { _l = l[2]; - _accu = f(accu, l[1]); + _accu = Caml_curry.app2(f, accu, l[1]); } else { return accu; @@ -198,7 +199,7 @@ function fold_left(f, _accu, _l) { function fold_right(f, l, accu) { if (l) { - return f(l[1], fold_right(f, l[2], accu)); + return Caml_curry.app2(f, l[1], fold_right(f, l[2], accu)); } else { return accu; @@ -208,7 +209,7 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - var r = f(l1[1], l2[1]); + var r = Caml_curry.app2(f, l1[1], l2[1]); return [ /* :: */0, r, @@ -241,7 +242,7 @@ function rev_map2(f, l1, l2) { _l1 = l1$1[2]; _accu = [ /* :: */0, - f(l1$1[1], l2$1[1]), + Caml_curry.app2(f, l1$1[1], l2$1[1]), accu ]; } @@ -264,7 +265,7 @@ function iter2(f, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - f(l1[1], l2[1]); + Caml_curry.app2(f, l1[1], l2[1]); _l2 = l2[2]; _l1 = l1[2]; } @@ -290,7 +291,7 @@ function fold_left2(f, _accu, _l1, _l2) { if (l2) { _l2 = l2[2]; _l1 = l1[2]; - _accu = f(accu, l1[1], l2[1]); + _accu = Caml_curry.app3(f, accu, l1[1], l2[1]); } else { return Pervasives.invalid_arg("List.fold_left2"); @@ -308,7 +309,7 @@ function fold_left2(f, _accu, _l1, _l2) { function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return f(l1[1], l2[1], fold_right2(f, l1[2], l2[2], accu)); + return Caml_curry.app3(f, l1[1], l2[1], fold_right2(f, l1[2], l2[2], accu)); } else { return Pervasives.invalid_arg("List.fold_right2"); @@ -326,7 +327,7 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[1])) { + if (Caml_curry.app1(p, param[1])) { _param = param[2]; } else { @@ -343,7 +344,7 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[1])) { + if (Caml_curry.app1(p, param[1])) { return /* true */1; } else { @@ -362,7 +363,7 @@ function for_all2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (p(l1[1], l2[1])) { + if (Caml_curry.app2(p, l1[1], l2[1])) { _l2 = l2[2]; _l1 = l1[2]; } @@ -389,7 +390,7 @@ function exists2(p, _l1, _l2) { var l1 = _l1; if (l1) { if (l2) { - if (p(l1[1], l2[1])) { + if (Caml_curry.app2(p, l1[1], l2[1])) { return /* true */1; } else { @@ -559,7 +560,7 @@ function find(p, _param) { var param = _param; if (param) { var x = param[1]; - if (p(x)) { + if (Caml_curry.app1(p, x)) { return x; } else { @@ -582,7 +583,7 @@ function find_all(p) { if (param$1) { var l = param$1[2]; var x = param$1[1]; - if (p(x)) { + if (Caml_curry.app1(p, x)) { _param = l; _accu = [ /* :: */0, @@ -612,7 +613,7 @@ function partition(p, l) { if (param) { var l$1 = param[2]; var x = param[1]; - if (p(x)) { + if (Caml_curry.app1(p, x)) { _param = l$1; _yes = [ /* :: */0, @@ -696,7 +697,7 @@ function merge(cmp, l1, l2) { if (l2) { var h2 = l2[1]; var h1 = l1[1]; - if (cmp(h1, h2) <= 0) { + if (Caml_curry.app2(cmp, h1, h2) <= 0) { return [ /* :: */0, h1, @@ -763,8 +764,8 @@ function stable_sort(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { + if (Caml_curry.app2(cmp, x1, x2) <= 0) { + if (Caml_curry.app2(cmp, x2, x3) <= 0) { return [ /* :: */0, x1, @@ -779,7 +780,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x1, x3) <= 0) { + else if (Caml_curry.app2(cmp, x1, x3) <= 0) { return [ /* :: */0, x1, @@ -810,7 +811,7 @@ function stable_sort(cmp, l) { ]; } } - else if (cmp(x1, x3) <= 0) { + else if (Caml_curry.app2(cmp, x1, x3) <= 0) { return [ /* :: */0, x2, @@ -825,7 +826,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x2, x3) <= 0) { + else if (Caml_curry.app2(cmp, x2, x3) <= 0) { return [ /* :: */0, x2, @@ -873,7 +874,7 @@ function stable_sort(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - if (cmp(x1$1, x2$1) <= 0) { + if (Caml_curry.app2(cmp, x1$1, x2$1) <= 0) { return [ /* :: */0, x1$1, @@ -920,7 +921,7 @@ function stable_sort(cmp, l) { if (l2$1) { var h2 = l2$1[1]; var h1 = l1[1]; - if (cmp(h1, h2) > 0) { + if (Caml_curry.app2(cmp, h1, h2) > 0) { _accu = [ /* :: */0, h1, @@ -962,8 +963,8 @@ function stable_sort(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { + if (Caml_curry.app2(cmp, x1, x2) > 0) { + if (Caml_curry.app2(cmp, x2, x3) > 0) { return [ /* :: */0, x1, @@ -978,7 +979,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x1, x3) > 0) { + else if (Caml_curry.app2(cmp, x1, x3) > 0) { return [ /* :: */0, x1, @@ -1009,7 +1010,7 @@ function stable_sort(cmp, l) { ]; } } - else if (cmp(x1, x3) > 0) { + else if (Caml_curry.app2(cmp, x1, x3) > 0) { return [ /* :: */0, x2, @@ -1024,7 +1025,7 @@ function stable_sort(cmp, l) { ] ]; } - else if (cmp(x2, x3) > 0) { + else if (Caml_curry.app2(cmp, x2, x3) > 0) { return [ /* :: */0, x2, @@ -1072,7 +1073,7 @@ function stable_sort(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - if (cmp(x1$1, x2$1) > 0) { + if (Caml_curry.app2(cmp, x1$1, x2$1) > 0) { return [ /* :: */0, x1$1, @@ -1119,7 +1120,7 @@ function stable_sort(cmp, l) { if (l2$1) { var h2 = l2$1[1]; var h1 = l1[1]; - if (cmp(h1, h2) <= 0) { + if (Caml_curry.app2(cmp, h1, h2) <= 0) { _accu = [ /* :: */0, h1, @@ -1171,10 +1172,10 @@ function sort_uniq(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - var c = cmp(x1, x2); + var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c < 0) { - var c$1 = cmp(x2, x3); + var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 < 0) { return [ @@ -1192,7 +1193,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$2 = cmp(x1, x3); + var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 < 0) { return [ @@ -1251,7 +1252,7 @@ function sort_uniq(cmp, l) { } } else { - var c$3 = cmp(x1, x3); + var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 < 0) { return [ @@ -1269,7 +1270,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$4 = cmp(x2, x3); + var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 < 0) { return [ @@ -1329,7 +1330,7 @@ function sort_uniq(cmp, l) { } } else { - var c$5 = cmp(x2, x3); + var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 < 0) { return [ @@ -1380,7 +1381,7 @@ function sort_uniq(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - var c$6 = cmp(x1$1, x2$1); + var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 < 0) { return [ @@ -1439,7 +1440,7 @@ function sort_uniq(cmp, l) { var h2 = l2$1[1]; var t1 = l1[2]; var h1 = l1[1]; - var c$7 = cmp(h1, h2); + var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 > 0) { _accu = [ @@ -1493,10 +1494,10 @@ function sort_uniq(cmp, l) { var x3 = match$1[1]; var x2 = match[1]; var x1 = l[1]; - var c = cmp(x1, x2); + var c = Caml_curry.app2(cmp, x1, x2); if (c) { if (c > 0) { - var c$1 = cmp(x2, x3); + var c$1 = Caml_curry.app2(cmp, x2, x3); if (c$1) { if (c$1 > 0) { return [ @@ -1514,7 +1515,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$2 = cmp(x1, x3); + var c$2 = Caml_curry.app2(cmp, x1, x3); if (c$2) { if (c$2 > 0) { return [ @@ -1573,7 +1574,7 @@ function sort_uniq(cmp, l) { } } else { - var c$3 = cmp(x1, x3); + var c$3 = Caml_curry.app2(cmp, x1, x3); if (c$3) { if (c$3 > 0) { return [ @@ -1591,7 +1592,7 @@ function sort_uniq(cmp, l) { ]; } else { - var c$4 = cmp(x2, x3); + var c$4 = Caml_curry.app2(cmp, x2, x3); if (c$4) { if (c$4 > 0) { return [ @@ -1651,7 +1652,7 @@ function sort_uniq(cmp, l) { } } else { - var c$5 = cmp(x2, x3); + var c$5 = Caml_curry.app2(cmp, x2, x3); if (c$5) { if (c$5 > 0) { return [ @@ -1702,7 +1703,7 @@ function sort_uniq(cmp, l) { if (match$2) { var x2$1 = match$2[1]; var x1$1 = l[1]; - var c$6 = cmp(x1$1, x2$1); + var c$6 = Caml_curry.app2(cmp, x1$1, x2$1); if (c$6) { if (c$6 > 0) { return [ @@ -1761,7 +1762,7 @@ function sort_uniq(cmp, l) { var h2 = l2$1[1]; var t1 = l1[2]; var h1 = l1[1]; - var c$7 = cmp(h1, h2); + var c$7 = Caml_curry.app2(cmp, h1, h2); if (c$7) { if (c$7 < 0) { _accu = [ diff --git a/jscomp/test/test_match_exception.js b/jscomp/test/test_match_exception.js index 156a1b4c48..c0ea4dea4c 100644 --- a/jscomp/test/test_match_exception.js +++ b/jscomp/test/test_match_exception.js @@ -2,10 +2,11 @@ 'use strict'; var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); function f(g, x) { try { - return g(x); + return Caml_curry.app1(g, x); } catch (exn){ if (exn === Caml_exceptions.Not_found) { diff --git a/jscomp/test/test_nested_print.js b/jscomp/test/test_nested_print.js index 7723227e0e..f7ec2a130b 100644 --- a/jscomp/test/test_nested_print.js +++ b/jscomp/test/test_nested_print.js @@ -1,13 +1,14 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); function u(_, x) { return x + x; } function f(g, x) { - var u = g(x); + var u = Caml_curry.app1(g, x); return u + u; } diff --git a/jscomp/test/test_obj.js b/jscomp/test/test_obj.js index 34bef0a144..522ae66912 100644 --- a/jscomp/test/test_obj.js +++ b/jscomp/test/test_obj.js @@ -1,10 +1,11 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_oo = require("../runtime/caml_oo"); +var Caml_oo = require("../runtime/caml_oo"); +var Caml_curry = require("../runtime/caml_curry"); function f(x) { - return Caml_oo.caml_get_public_method(x, 623642069, 1)(x); + return Caml_curry.app1(Caml_oo.caml_get_public_method(x, 623642069, 1), x); } exports.f = f; diff --git a/jscomp/test/test_per.js b/jscomp/test/test_per.js index 9193af85a3..49456da75e 100644 --- a/jscomp/test/test_per.js +++ b/jscomp/test/test_per.js @@ -7,6 +7,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_format = require("../runtime/caml_format"); var Caml_primitive = require("../runtime/caml_primitive"); var CamlinternalFormatBasics = require("../stdlib/camlinternalFormatBasics"); +var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); function failwith(s) { @@ -546,18 +547,18 @@ var exit_function = [ function at_exit(f) { var g = exit_function[1]; exit_function[1] = function () { - f(/* () */0); - return g(/* () */0); + Caml_curry.app1(f, /* () */0); + return Caml_curry.app1(g, /* () */0); }; return /* () */0; } function do_at_exit() { - return exit_function[1](/* () */0); + return Caml_curry.app1(exit_function[1], /* () */0); } function exit(retcode) { - exit_function[1](/* () */0); + Caml_curry.app1(exit_function[1], /* () */0); return Caml_primitive.caml_sys_exit(retcode); } diff --git a/jscomp/test/test_primitive.js b/jscomp/test/test_primitive.js index 997bfc984a..bc410496a6 100644 --- a/jscomp/test/test_primitive.js +++ b/jscomp/test/test_primitive.js @@ -4,6 +4,7 @@ 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 [ @@ -59,7 +60,7 @@ function u(b) { } function f2(h, b, _) { - return h(b ? 32 : 7); + return Caml_curry.app1(h, b ? 32 : 7); } v[1] = 3.0; diff --git a/jscomp/test/test_react.js b/jscomp/test/test_react.js index e8aedc8845..7eb39bbc9e 100644 --- a/jscomp/test/test_react.js +++ b/jscomp/test/test_react.js @@ -1,23 +1,24 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var React = require("@"); -var React = require("react"); -var ReactDom = require("react-dom"); +var React = require("@"); +var React = require("react"); +var Caml_curry = require("../runtime/caml_curry"); +var ReactDom = require("react-dom"); -console.log("hey"); +Caml_curry.app1(console.log, "hey"); -doc.getElementById("haha"); +Caml_curry.app1(doc.getElementById, "haha"); -var v = console.log(32); +var v = Caml_curry.app1(console.log, 32); -ReactDom.render(React.createClass({ +Caml_curry.app2(ReactDom.render, Caml_curry.app1(React.createClass, { "render": function () { - return React.DOM.div({ + return Caml_curry.app4(React.DOM.div, { "alt": "pic" - }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!"), React.DOM.h3(null, "type safe!")); + }, Caml_curry.app2(React.DOM.h1, null, "hello react"), Caml_curry.app2(React.DOM.h2, null, "type safe!"), Caml_curry.app2(React.DOM.h3, null, "type safe!")); } - }), document.getElementById("hi")); + }), Caml_curry.app1(document.getElementById, "hi")); var u = 33; diff --git a/jscomp/test/test_scope.js b/jscomp/test/test_scope.js index f7d577426d..6cf7206f1c 100644 --- a/jscomp/test/test_scope.js +++ b/jscomp/test/test_scope.js @@ -1,10 +1,11 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); -var h = uuu.x(3); +var h = Caml_curry.app1(uuu.x, 3); -var hh = x(3); +var hh = Caml_curry.app1(x, 3); function f(x, y) { return x + y; diff --git a/jscomp/test/test_seq.js b/jscomp/test/test_seq.js index 963948214b..2c302eb117 100644 --- a/jscomp/test/test_seq.js +++ b/jscomp/test/test_seq.js @@ -4,6 +4,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); var Pervasives = require("../stdlib/pervasives"); var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); var Bad = [ 248, @@ -58,7 +59,7 @@ function v(speclist) { } function f(g, speclist) { - return g(assoc3("-help", speclist)); + return Caml_curry.app1(g, assoc3("-help", speclist)); } function add_help(speclist) { diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index 9581df806e..aa9f523199 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -3,6 +3,7 @@ var Pervasives = require("../stdlib/pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); function Make(Ord) { @@ -81,7 +82,7 @@ function Make(Ord) { var r = t[3]; var v = t[2]; var l = t[1]; - var c = Ord[1](x, v); + var c = Caml_curry.app2(Ord[1], x, v); if (c) { if (c < 0) { return bal(add(x, l), v, r); @@ -231,7 +232,7 @@ function Make(Ord) { var r = param[3]; var v = param[2]; var l = param[1]; - var c = Ord[1](x, v); + var c = Caml_curry.app2(Ord[1], x, v); if (c) { if (c < 0) { var match = split(x, l); @@ -283,7 +284,7 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - var c = Ord[1](x, param[2]); + var c = Caml_curry.app2(Ord[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[3]; } @@ -301,7 +302,7 @@ function Make(Ord) { var r = param[3]; var v = param[2]; var l = param[1]; - var c = Ord[1](x, v); + var c = Caml_curry.app2(Ord[1], x, v); if (c) { if (c < 0) { return bal(remove(x, l), v, r); @@ -420,7 +421,7 @@ function Make(Ord) { var e1 = _e1; if (e1) { if (e2) { - var c = Ord[1](e1[1], e2[1]); + var c = Caml_curry.app2(Ord[1], e1[1], e2[1]); if (c !== 0) { return c; } @@ -458,7 +459,7 @@ function Make(Ord) { var r1 = s1[3]; var v1 = s1[2]; var l1 = s1[1]; - var c = Ord[1](v1, s2[2]); + var c = Caml_curry.app2(Ord[1], v1, s2[2]); if (c) { if (c < 0) { if (subset([ @@ -509,7 +510,7 @@ function Make(Ord) { var param = _param; if (param) { iter(f, param[1]); - f(param[2]); + Caml_curry.app1(f, param[2]); _param = param[3]; } else { @@ -522,7 +523,7 @@ function Make(Ord) { var accu = _accu; var s = _s; if (s) { - _accu = f(s[2], fold(f, s[1], accu)); + _accu = Caml_curry.app2(f, s[2], fold(f, s[1], accu)); _s = s[3]; } else { @@ -534,7 +535,7 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - if (p(param[2])) { + if (Caml_curry.app1(p, param[2])) { if (for_all(p, param[1])) { _param = param[3]; } @@ -555,7 +556,7 @@ function Make(Ord) { while(true) { var param = _param; if (param) { - if (p(param[2])) { + if (Caml_curry.app1(p, param[2])) { return /* true */1; } else if (exists(p, param[1])) { @@ -574,7 +575,7 @@ function Make(Ord) { if (param) { var v = param[2]; var l$prime = filter(p, param[1]); - var pv = p(v); + var pv = Caml_curry.app1(p, v); var r$prime = filter(p, param[3]); if (pv) { return join(l$prime, v, r$prime); @@ -593,7 +594,7 @@ function Make(Ord) { var match = partition(p, param[1]); var lf = match[2]; var lt = match[1]; - var pv = p(v); + var pv = Caml_curry.app1(p, v); var match$1 = partition(p, param[3]); var rf = match$1[2]; var rt = match$1[1]; @@ -653,7 +654,7 @@ function Make(Ord) { var param = _param; if (param) { var v = param[2]; - var c = Ord[1](x, v); + var c = Caml_curry.app2(Ord[1], x, v); if (c) { _param = c < 0 ? param[1] : param[3]; } diff --git a/jscomp/test/test_simple_obj.js b/jscomp/test/test_simple_obj.js index a4300ae883..68d5c77e25 100644 --- a/jscomp/test/test_simple_obj.js +++ b/jscomp/test/test_simple_obj.js @@ -4,6 +4,7 @@ var Caml_oo = require("../runtime/caml_oo"); var Caml_exceptions = require("../runtime/caml_exceptions"); var CamlinternalOO = require("../stdlib/camlinternalOO"); +var Caml_curry = require("../runtime/caml_curry"); var shared = [ 0, @@ -97,7 +98,7 @@ CamlinternalOO.init_class($$class$3); var v = CamlinternalOO.create_object_opt(0, $$class$3); function test() { - if (Caml_oo.caml_get_public_method(uu, 23515, 1)(uu) !== "uu") { + if (Caml_curry.app1(Caml_oo.caml_get_public_method(uu, 23515, 1), uu) !== "uu") { throw [ 0, Caml_exceptions.Assert_failure, @@ -109,7 +110,7 @@ function test() { ] ]; } - if (Caml_oo.caml_get_public_method(uuu, 4846113, 2)(uuu, 1, 20) !== 21) { + if (Caml_curry.app3(Caml_oo.caml_get_public_method(uuu, 4846113, 2), uuu, 1, 20) !== 21) { throw [ 0, Caml_exceptions.Assert_failure, @@ -121,7 +122,7 @@ function test() { ] ]; } - if (Caml_oo.caml_get_public_method(v, 4846113, 3)(v, 3, 7) !== 10) { + if (Caml_curry.app3(Caml_oo.caml_get_public_method(v, 4846113, 3), v, 3, 7) !== 10) { throw [ 0, Caml_exceptions.Assert_failure, @@ -133,7 +134,7 @@ function test() { ] ]; } - if (Caml_oo.caml_get_public_method(u, 5243894, 4)(u) !== 3) { + if (Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243894, 4), u) !== 3) { throw [ 0, Caml_exceptions.Assert_failure, @@ -145,7 +146,7 @@ function test() { ] ]; } - if (Caml_oo.caml_get_public_method(u, 5243895, 5)(u) !== 4) { + if (Caml_curry.app1(Caml_oo.caml_get_public_method(u, 5243895, 5), u) !== 4) { throw [ 0, Caml_exceptions.Assert_failure, @@ -157,7 +158,7 @@ function test() { ] ]; } - if (Caml_oo.caml_get_public_method(u, 23297, 6)(u, 1, 2) !== 3) { + if (Caml_curry.app3(Caml_oo.caml_get_public_method(u, 23297, 6), u, 1, 2) !== 3) { throw [ 0, Caml_exceptions.Assert_failure, @@ -169,7 +170,7 @@ function test() { ] ]; } - if (Caml_oo.caml_get_public_method(u, 616641298, 7)(u, 32) === 32) { + if (Caml_curry.app2(Caml_oo.caml_get_public_method(u, 616641298, 7), u, 32) === 32) { return 0; } else { diff --git a/jscomp/test/test_simple_ref.js b/jscomp/test/test_simple_ref.js index 05f6687c63..e53cadcbd4 100644 --- a/jscomp/test/test_simple_ref.js +++ b/jscomp/test/test_simple_ref.js @@ -1,6 +1,7 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); var v = [ 0, @@ -27,7 +28,7 @@ var c = [ var not_real_escape = a; function real_escape(f, _) { - return f(c); + return Caml_curry.app1(f, c); } var u = h; diff --git a/jscomp/test/test_sprintf.js b/jscomp/test/test_sprintf.js index 5be204978f..f565f5589a 100644 --- a/jscomp/test/test_sprintf.js +++ b/jscomp/test/test_sprintf.js @@ -1,22 +1,23 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Printf = require("../stdlib/printf"); +var Printf = require("../stdlib/printf"); +var Caml_curry = require("../runtime/caml_curry"); -console.error(Printf.sprintf([ - /* Format */0, - [ - /* Int */4, - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, +console.error(Caml_curry.app2(Printf.sprintf([ + /* Format */0, [ - /* String */2, + /* Int */4, + /* Int_d */0, /* No_padding */0, - /* End_of_format */0 - ] - ], - "%d%s" - ])(32, "ss")); + /* No_precision */0, + [ + /* String */2, + /* No_padding */0, + /* End_of_format */0 + ] + ], + "%d%s" + ]), 32, "ss")); /* Not a pure module */ diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index df79f73b1c..b7b20b4f5b 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -3,6 +3,7 @@ var Pervasives = require("../stdlib/pervasives"); var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); var Caml_string = require("../runtime/caml_string"); function height(param) { @@ -139,9 +140,9 @@ function find(x, _param) { } function timing(label, f) { - console.time(label); - f(/* () */0); - return console.timeEnd(label); + Caml_curry.app1(console.time, label); + Caml_curry.app1(f, /* () */0); + return Caml_curry.app1(console.timeEnd, label); } function assertion_test() { diff --git a/jscomp/test/test_switch.js b/jscomp/test/test_switch.js index e97542b95f..7d652575e5 100644 --- a/jscomp/test/test_switch.js +++ b/jscomp/test/test_switch.js @@ -1,6 +1,7 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); function f(param) { if (typeof param === "number") { @@ -33,7 +34,7 @@ function bind(x, f) { else { return [ /* Left */0, - f(x[1]) + Caml_curry.app1(f, x[1]) ]; } } diff --git a/jscomp/test/test_type_based_arity.js b/jscomp/test/test_type_based_arity.js index db04fec404..68b4df1ca4 100644 --- a/jscomp/test/test_type_based_arity.js +++ b/jscomp/test/test_type_based_arity.js @@ -1,65 +1,66 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; +var Caml_curry = require("../runtime/caml_curry"); function f0(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f1(g, x) { - return g(x); + return Caml_curry.app1(g, x); } var X = [0]; function f2(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f3(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f4(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f5(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f6(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f7(g, x) { - return g(x); + return Caml_curry.app1(g, x); } var X0 = [0]; function f8(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f9(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f10(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f11(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f12(g, x) { - return g(x); + return Caml_curry.app1(g, x); } function f13(g, x) { - return g(x); + return Caml_curry.app1(g, x); } var X2 = [ @@ -68,7 +69,7 @@ var X2 = [ ]; function f14(h, g, x) { - return h(g, x); + return Caml_curry.app2(h, g, x); } exports.f0 = f0; diff --git a/jscomp/test/test_while_closure.js b/jscomp/test/test_while_closure.js index bfec46ea91..27f9b83f69 100644 --- a/jscomp/test/test_while_closure.js +++ b/jscomp/test/test_while_closure.js @@ -4,6 +4,7 @@ var Caml_exceptions = require("../runtime/caml_exceptions"); var Caml_array = require("../runtime/caml_array"); var $$Array = require("../stdlib/array"); +var Caml_curry = require("../runtime/caml_curry"); var v = [ 0, @@ -34,7 +35,7 @@ function f() { f(/* () */0); $$Array.iter(function (x) { - return x(/* () */0); + return Caml_curry.app1(x, /* () */0); }, arr); console.log("" + v[1]); diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 08b77080f3..11534bbee4 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -7,6 +7,7 @@ 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"); function split(delim, s) { @@ -88,25 +89,25 @@ function string_of_rank(param) { } } else { - return Printf.sprintf([ - /* Format */0, - [ - /* String_literal */11, - "Ranked(", + return Caml_curry.app1(Printf.sprintf([ + /* Format */0, [ - /* Int */4, - /* Int_i */3, - /* No_padding */0, - /* No_precision */0, + /* String_literal */11, + "Ranked(", [ - /* Char_literal */12, - /* ")" */41, - /* End_of_format */0 + /* Int */4, + /* Int_i */3, + /* No_padding */0, + /* No_precision */0, + [ + /* Char_literal */12, + /* ")" */41, + /* End_of_format */0 + ] ] - ] - ], - "Ranked(%i)" - ])(param[1]); + ], + "Ranked(%i)" + ]), param[1]); } } @@ -408,7 +409,7 @@ function iter(f, _param) { var param = _param; if (param) { iter(f, param[1]); - f(param[2], param[3]); + Caml_curry.app2(f, param[2], param[3]); _param = param[4]; } else { @@ -420,7 +421,7 @@ function iter(f, _param) { function map(f, param) { if (param) { var l$prime = map(f, param[1]); - var d$prime = f(param[3]); + var d$prime = Caml_curry.app1(f, param[3]); var r$prime = map(f, param[4]); return [ /* Node */0, @@ -440,7 +441,7 @@ function mapi(f, param) { if (param) { var v = param[2]; var l$prime = mapi(f, param[1]); - var d$prime = f(v, param[3]); + var d$prime = Caml_curry.app2(f, v, param[3]); var r$prime = mapi(f, param[4]); return [ /* Node */0, @@ -461,7 +462,7 @@ function fold(f, _m, _accu) { var accu = _accu; var m = _m; if (m) { - _accu = f(m[2], m[3], fold(f, m[1], accu)); + _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; } else { @@ -474,7 +475,7 @@ function for_all(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; } @@ -496,7 +497,7 @@ function exists(p, _param) { while(true) { var param = _param; if (param) { - if (p(param[2], param[3])) { + if (Caml_curry.app2(p, param[2], param[3])) { return /* true */1; } else if (exists(p, param[1])) { @@ -633,7 +634,7 @@ function merge(f, s1, s2) { var v1 = s1[2]; if (s1[5] >= height(s2)) { var match = split$1(v1, s2); - return concat_or_join(merge(f, s1[1], match[1]), v1, f(v1, [ + 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])); @@ -652,7 +653,7 @@ function merge(f, s1, s2) { if (s2) { var v2 = s2[2]; var match$1 = split$1(v2, s1); - return concat_or_join(merge(f, match$1[1], s2[1]), v2, f(v2, match$1[2], [ + 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])); @@ -678,7 +679,7 @@ function filter(p, param) { var d = param[3]; var v = param[2]; var l$prime = filter(p, param[1]); - var pvd = p(v, d); + var pvd = Caml_curry.app2(p, v, d); var r$prime = filter(p, param[4]); if (pvd) { return join(l$prime, v, d, r$prime); @@ -699,7 +700,7 @@ function partition(p, param) { var match = partition(p, param[1]); var lf = match[2]; var lt = match[1]; - var pvd = p(v, d); + 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]; @@ -760,7 +761,7 @@ function compare(cmp, m1, m2) { return c; } else { - var c$1 = cmp(e1[2], e2[2]); + var c$1 = Caml_curry.app2(cmp, e1[2], e2[2]); if (c$1 !== 0) { return c$1; } @@ -794,7 +795,7 @@ function equal(cmp, m1, m2) { if (Caml_primitive.caml_compare(e1[1], e2[1])) { return /* false */0; } - else if (cmp(e1[2], e2[2])) { + else if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); } From 31319baf17e4d44a39cf49bb60a89e794aa905da Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Sat, 6 Feb 2016 09:43:08 -0500 Subject: [PATCH 2/5] add a test example --- jscomp/test/.depend | 8 ++--- jscomp/test/printf_test.d.ts | 1 + jscomp/test/printf_test.js | 65 ++++++++++++++++++++++++++++++++++-- jscomp/test/printf_test.ml | 5 +-- 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/jscomp/test/.depend b/jscomp/test/.depend index d09a86ead0..520a3f4bd6 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -136,8 +136,8 @@ of_string_test.cmo : mt.cmo of_string_test.cmx : mt.cmx primitive_reg_test.cmo : primitive_reg_test.cmx : -printf_test.cmo : ../stdlib/printf.cmi mt.cmo -printf_test.cmx : ../stdlib/printf.cmx mt.cmx +printf_test.cmo : ../stdlib/printf.cmi mt.cmo ../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 \ ../stdlib/array.cmi @@ -496,8 +496,8 @@ of_string_test.cmo : mt.cmo of_string_test.cmj : mt.cmj primitive_reg_test.cmo : primitive_reg_test.cmj : -printf_test.cmo : ../stdlib/printf.cmi mt.cmo -printf_test.cmj : ../stdlib/printf.cmj mt.cmj +printf_test.cmo : ../stdlib/printf.cmi mt.cmo ../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 \ ../stdlib/array.cmi diff --git a/jscomp/test/printf_test.d.ts b/jscomp/test/printf_test.d.ts index cab0dc909f..9e94dea909 100644 --- a/jscomp/test/printf_test.d.ts +++ b/jscomp/test/printf_test.d.ts @@ -1,2 +1,3 @@ +export var print_pair: (fmt : any, param : any) => any ; export var suites: any ; diff --git a/jscomp/test/printf_test.js b/jscomp/test/printf_test.js index 1d0a4d6c74..30dd4ecade 100644 --- a/jscomp/test/printf_test.js +++ b/jscomp/test/printf_test.js @@ -4,6 +4,39 @@ var Mt = require("./mt"); var Printf = require("../stdlib/printf"); 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]); +} var suites_001 = [ /* tuple */0, @@ -31,13 +64,41 @@ var suites_001 = [ } ]; +var suites_002 = [ + /* :: */0, + [ + /* tuple */0, + "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, + 1, + 2 + ]) + ]; + } + ], + /* [] */0 +]; + var suites = [ /* :: */0, suites_001, - /* [] */0 + suites_002 ]; Mt.from_pair_suites("printf_test.ml", suites); -exports.suites = suites; +exports.print_pair = print_pair; +exports.suites = suites; /* Not a pure module */ diff --git a/jscomp/test/printf_test.ml b/jscomp/test/printf_test.ml index 8220480a82..1e44cd7f50 100644 --- a/jscomp/test/printf_test.ml +++ b/jscomp/test/printf_test.ml @@ -1,8 +1,9 @@ - +let print_pair fmt (a,b) = Format.fprintf fmt "(%d,%d)" a b let suites = Mt.[ - "sprintf_simple", (fun _ -> Eq("3232", Printf.sprintf "%s%d" "32" 32)) + "sprintf_simple", (fun _ -> Eq("3232", Printf.sprintf "%s%d" "32" 32)); + "print_pair", (fun _ -> Eq("(1,2)", Format.asprintf "%a" print_pair (1,2))) ] From 0da113492dd479b33c5d73e9e32305442d17892f Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Sat, 6 Feb 2016 12:47:12 -0500 Subject: [PATCH 3/5] fix js_call --- jscomp/js_dump.ml | 23 ++-- jscomp/lam_compile.ml | 6 +- jscomp/lam_compile_external_call.ml | 2 +- jscomp/runtime/curry.d.ts | 18 --- jscomp/runtime/curry.js | 207 ---------------------------- jscomp/test/curry.d.ts | 9 -- jscomp/test/curry_raw_test.js | 19 ++- jscomp/test/demo.js | 8 +- jscomp/test/demo_page.js | 6 +- jscomp/test/mt.js | 16 +-- jscomp/test/number_lexer.js | 2 +- jscomp/test/test_ari.js | 4 +- jscomp/test/test_external.d.ts | 1 + jscomp/test/test_external.js | 7 +- jscomp/test/test_external.ml | 7 + jscomp/test/test_ffi.js | 3 +- jscomp/test/test_js_ffi.js | 5 +- jscomp/test/test_react.js | 8 +- jscomp/test/test_scope.js | 5 +- jscomp/test/test_string_map.js | 4 +- 20 files changed, 74 insertions(+), 286 deletions(-) delete mode 100644 jscomp/runtime/curry.d.ts delete mode 100644 jscomp/runtime/curry.js delete mode 100644 jscomp/test/curry.d.ts diff --git a/jscomp/js_dump.ml b/jscomp/js_dump.ml index 03caa350d7..907d8630ae 100644 --- a/jscomp/js_dump.ml +++ b/jscomp/js_dump.ml @@ -87,6 +87,8 @@ module L = struct let define = "define" let break = "break" let strict_directive = "'use strict';" + + let curry = "curry" (* curry arbitrary args *) end let return_indent = (String.length L.return / Ext_pp.indent_length) @@ -393,24 +395,27 @@ and | Call (e, el, info) -> let action () = P.group f 1 (fun _ -> + match info, el with + | {arity = Full }, _ + | _, [] -> + let cxt = expression 15 cxt f e in + P.paren_group f 1 (fun _ -> arguments cxt f el ) - match info with - | {arity = NA } -> + | _ , _ -> (* ipp_comment f (Some "!") *) P.string f Js_config.curry; P.string f L.dot; let len = List.length el in - if len <= 8 then + if 1 <= len && len <= 8 then begin P.string f (Printf.sprintf "app%d" len); P.paren_group f 1 (fun _ -> arguments cxt f (e::el)) end - else assert false (* TODO *) - (* let cxt = expression 15 cxt f e in *) - (* P.paren_group f 1 (fun _ -> arguments cxt f el ) ) *) - | _ -> - let cxt = expression 15 cxt f e in - P.paren_group f 1 (fun _ -> arguments cxt f el ) ) + else + begin + P.string f L.curry; + P.paren_group f 1 (fun _ -> arguments cxt f [ e ; E.arr Mutable el]) + end) in if l > 15 then P.paren_group f 1 action else action () diff --git a/jscomp/lam_compile.ml b/jscomp/lam_compile.ml index afdb84a65b..ca9bd1fa8f 100644 --- a/jscomp/lam_compile.ml +++ b/jscomp/lam_compile.ml @@ -405,9 +405,9 @@ and | _ -> Js_output.handle_block_return st should_return lam (List.concat args_code ) - (E.call ~info:(match info with - | { apply_status = Full} -> {arity = Full } - | { apply_status = NA} -> {arity = NA} ) fn_code args) + (E.call ~info:(match fn, info with + | _, { apply_status = Full} -> {arity = Full } + | _, { apply_status = NA} -> {arity = NA} ) fn_code args) end; end diff --git a/jscomp/lam_compile_external_call.ml b/jscomp/lam_compile_external_call.ml index b73f7aff3c..b5276432b9 100644 --- a/jscomp/lam_compile_external_call.ml +++ b/jscomp/lam_compile_external_call.ml @@ -316,7 +316,7 @@ let translate | _ -> assert false end in - E.call fn args + E.call ~info:{arity=Full} fn args | None -> assert false end | Js_new { external_module_name = module_name; diff --git a/jscomp/runtime/curry.d.ts b/jscomp/runtime/curry.d.ts deleted file mode 100644 index 211a328dc5..0000000000 --- a/jscomp/runtime/curry.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -export var curry: (f : any, args : any) => any ; -export var curry1: (o : any, x : any, arity : any) => any ; -export var app1: (o : any, x : any) => any ; -export var app2: (o : any, x : any, y : any) => any ; -export var app3: (o : any, a0 : any, a1 : any, a2 : any) => any ; -export var app4: (o : any, a0 : any, a1 : any, a2 : any, a3 : any) => any ; -export var app5: - (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any) => any ; -export var app6: - (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any, a5 : any) => - any ; -export var app7: - (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any, a5 : any, - a6 : any) => any ; -export var app8: - (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any, a5 : any, - a6 : any, a7 : any) => any ; - diff --git a/jscomp/runtime/curry.js b/jscomp/runtime/curry.js deleted file mode 100644 index 85b19d1ff3..0000000000 --- a/jscomp/runtime/curry.js +++ /dev/null @@ -1,207 +0,0 @@ -// Generated CODE, PLEASE EDIT WITH CARE -'use strict'; - -var Caml_array = require("./caml_array"); - -function curry(_f, _args) { - while(true) { - var args = _args; - var f = _f; - var arity = f.length; - var len = args.length; - var d = arity - len; - if (d) { - if (d < 0) { - _args = Caml_array.caml_array_sub(args, arity, -d); - _f = f.apply(null, Caml_array.caml_array_sub(args, 0, arity)); - } - else { - return (function(f,args){ - return function (x) { - return curry(f, args.concat(/* array */[x])); - } - }(f,args)); - } - } - else { - return f.apply(null, args); - } - }; -} - -function curry1(o, x, arity) { - if (arity > 7 || arity < 0) { - return function (a) { - return curry(o, /* array */[ - x, - a - ]); - }; - } - else { - switch (arity) { - case 0 : - case 1 : - return o(x); - case 2 : - return function (param) { - return o(x, param); - }; - case 3 : - return function (param, param$1) { - return o(x, param, param$1); - }; - case 4 : - return function (param, param$1, param$2) { - return o(x, param, param$1, param$2); - }; - case 5 : - return function (param, param$1, param$2, param$3) { - return o(x, param, param$1, param$2, param$3); - }; - case 6 : - return function (param, param$1, param$2, param$3, param$4) { - return o(x, param, param$1, param$2, param$3, param$4); - }; - case 7 : - return function (param, param$1, param$2, param$3, param$4, param$5) { - return o(x, param, param$1, param$2, param$3, param$4, param$5); - }; - - } - } -} - -function app1(o, x) { - var len = o.length; - if (len === 1 || len === 0) { - return o(x); - } - else { - return curry1(o, x, len); - } -} - -function app2(o, x, y) { - var len = o.length; - if (len === 2) { - return o(x, y); - } - else { - return curry(o, /* array */[ - x, - y - ]); - } -} - -function app3(o, a0, a1, a2) { - var len = o.length; - if (len === 3) { - return o(a0, a1, a2); - } - else { - return curry(o, /* array */[ - a0, - a1, - a2 - ]); - } -} - -function app4(o, a0, a1, a2, a3) { - var len = o.length; - if (len === 4) { - return o(a0, a1, a2, a3); - } - else { - return curry(o, /* array */[ - a0, - a1, - a2, - a3 - ]); - } -} - -function app5(o, a0, a1, a2, a3, a4) { - var len = o.length; - if (len === 5) { - return o(a0, a1, a2, a3, a4); - } - else { - return curry(o, /* array */[ - a0, - a1, - a2, - a3, - a4 - ]); - } -} - -function app6(o, a0, a1, a2, a3, a4, a5) { - var len = o.length; - if (len === 6) { - return o(a0, a1, a2, a3, a4, a5); - } - else { - return curry(o, /* array */[ - a0, - a1, - a2, - a3, - a4, - a5 - ]); - } -} - -function app7(o, a0, a1, a2, a3, a4, a5, a6) { - var len = o.length; - if (len === 7) { - return o(a0, a1, a2, a3, a4, a5, a6); - } - else { - return curry(o, /* array */[ - a0, - a1, - a2, - a3, - a4, - a5, - a6 - ]); - } -} - -function app8(o, a0, a1, a2, a3, a4, a5, a6, a7) { - var len = o.length; - if (len === 8) { - return o(a0, a1, a2, a3, a4, a5, a6, a7); - } - else { - return curry(o, /* array */[ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7 - ]); - } -} - -exports.curry = curry; -exports.curry1 = curry1; -exports.app1 = app1; -exports.app2 = app2; -exports.app3 = app3; -exports.app4 = app4; -exports.app5 = app5; -exports.app6 = app6; -exports.app7 = app7; -exports.app8 = app8; -/* No side effect */ diff --git a/jscomp/test/curry.d.ts b/jscomp/test/curry.d.ts deleted file mode 100644 index adb1f1361e..0000000000 --- a/jscomp/test/curry.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export var curry: (f : any, args : any) => any ; -export var curry1: (o : any, x : any, arity : any) => any ; -export var app1: (o : any, x : any) => any ; -export var app2: (o : any, x : any, y : any) => any ; -export var app3: (o : any, a0 : any, a1 : any, a2 : any) => any ; -export var app4: (o : any, a0 : any, a1 : any, a2 : any, a3 : any) => any ; -export var app5: - (o : any, a0 : any, a1 : any, a2 : any, a3 : any, a4 : any) => any ; - diff --git a/jscomp/test/curry_raw_test.js b/jscomp/test/curry_raw_test.js index 12ec20ce9a..047922af7f 100644 --- a/jscomp/test/curry_raw_test.js +++ b/jscomp/test/curry_raw_test.js @@ -1,6 +1,6 @@ var assert = require("assert") var printf = require("./../stdlib/printf") -var curry = require("../runtime/curry") +var curry = require("../runtime/caml_curry") var test_formatter = require("./test_formatter") // Fmt can be defined other ocaml module : ) @@ -18,7 +18,7 @@ describe("curry", function(){ "32ss" ) } - ) + ); it("printf2",function(){ assert.deepEqual( curry.app1(curry.app2(printf.sprintf, @@ -28,7 +28,7 @@ describe("curry", function(){ ), "32ss" ) - }) + }); it("printf3",function(){ assert.deepEqual( curry.app1(curry.app1(curry.app1(printf.sprintf, @@ -38,5 +38,14 @@ describe("curry", function(){ ), "32ss" ) - }) -} ) \ No newline at end of file + }); + it("printf4",function(){ + assert.deepEqual( + curry.curry(printf.sprintf, + [test_formatter.f(), + 32, + "ss", + ] + ),"32ss" + )} + )}) \ No newline at end of file diff --git a/jscomp/test/demo.js b/jscomp/test/demo.js index a8ef3369d1..307eb76eb5 100644 --- a/jscomp/test/demo.js +++ b/jscomp/test/demo.js @@ -101,11 +101,11 @@ function ui_layout(compile, lookup, appContext) { return /* () */0; } }); - Caml_curry.app2(Runtime.setInterval, function () { - return grid.dataSource = Caml_curry.app2(Array.prototype.map.call, data, function (param) { + Runtime.setInterval(function () { + return grid.dataSource = Array.prototype.map.call(data, function (param) { var price = param[2]; - var bid = price + 20 * Caml_curry.app0(Math.random); - var ask = price + 20 * Caml_curry.app0(Math.random); + var bid = price + 20 * Math.random(); + var ask = price + 20 * Math.random(); var result = Caml_curry.app1(computeFunction[1], { "bid": bid, "ask": ask diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index e2a0f04fca..5f65fe7157 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -43,11 +43,11 @@ function f(param) { return 32 + param; } -Caml_curry.app2(ReactDom.render, Caml_curry.app1(React.createClass, { +ReactDom.render(React.createClass({ "render": function () { - return Caml_curry.app3(React.DOM.div, { + return React.DOM.div({ "alt": "pic" - }, Caml_curry.app2(React.DOM.h1, null, "hello react"), Caml_curry.app2(React.DOM.h2, null, "type safe!")); + }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!")); } }), Caml_curry.app1(document.getElementById, "hi")); diff --git a/jscomp/test/mt.js b/jscomp/test/mt.js index d2ab4992b4..53c39fce10 100644 --- a/jscomp/test/mt.js +++ b/jscomp/test/mt.js @@ -6,32 +6,32 @@ var Caml_curry = require("../runtime/caml_curry"); var List = require("../stdlib/list"); function assert_equal(prim, prim$1) { - return Caml_curry.app2(Assert.deepEqual, prim, prim$1); + return Assert.deepEqual(prim, prim$1); } function assert_notequal(prim, prim$1) { - return Caml_curry.app2(Assert.notDeepEqual, prim, prim$1); + return Assert.notDeepEqual(prim, prim$1); } function from_suites(name, suite) { - return Caml_curry.app2(describe, name, function () { + return describe(name, function () { return List.iter(function (param) { - return Caml_curry.app2(it, param[1], param[2]); + return it(param[1], param[2]); }, suite); }); } function from_pair_suites(name, suites) { - return Caml_curry.app2(describe, name, function () { + return describe(name, function () { return List.iter(function (param) { var code = param[2]; - return Caml_curry.app2(it, param[1], function () { + return it(param[1], function () { var match = Caml_curry.app1(code, /* () */0); if (match[0]) { - return Caml_curry.app2(Assert.notDeepEqual, match[1], match[2]); + return Assert.notDeepEqual(match[1], match[2]); } else { - return Caml_curry.app2(Assert.deepEqual, match[1], match[2]); + return Assert.deepEqual(match[1], match[2]); } }); }, suites); diff --git a/jscomp/test/number_lexer.js b/jscomp/test/number_lexer.js index 602887a3aa..f5cceb1042 100644 --- a/jscomp/test/number_lexer.js +++ b/jscomp/test/number_lexer.js @@ -7,7 +7,7 @@ var Sys = require("../stdlib/sys"); var Caml_curry = require("../runtime/caml_curry"); var l = Sys.is_js ? function (prim) { - return Caml_curry.app1(console.log, prim); + return console.log(prim); } : function (param) { return Pervasives.output_string(Pervasives.stdout, param); }; diff --git a/jscomp/test/test_ari.js b/jscomp/test/test_ari.js index d2348038bc..6d1d9b04a2 100644 --- a/jscomp/test/test_ari.js +++ b/jscomp/test/test_ari.js @@ -27,10 +27,10 @@ function f2(param) { var g = 7; function ff(param) { - return Caml_curry.app2(U.test_primit, 3, param); + return U.test_primit(3, param); } -var fff = Caml_curry.app1(VV.test_primit2, 3); +var fff = VV.test_primit2(3); function length_aux(_len, _param) { while(true) { diff --git a/jscomp/test/test_external.d.ts b/jscomp/test/test_external.d.ts index 9820321637..bfabc27a38 100644 --- a/jscomp/test/test_external.d.ts +++ b/jscomp/test/test_external.d.ts @@ -1,2 +1,3 @@ export var xx: any ; +export var b: any ; diff --git a/jscomp/test/test_external.js b/jscomp/test/test_external.js index 22e58dbf08..21b4ba960d 100644 --- a/jscomp/test/test_external.js +++ b/jscomp/test/test_external.js @@ -3,9 +3,12 @@ var Caml_curry = require("../runtime/caml_curry"); -var xx = Caml_curry.app0(document); +var xx = document(); -Caml_curry.app1(alert, "hehha"); +alert("hehha"); + +var b = Caml_curry.app1(ff("x"), 3); exports.xx = xx; +exports.b = b; /* xx Not a pure module */ diff --git a/jscomp/test/test_external.ml b/jscomp/test/test_external.ml index e8ca4a659c..fd69952bc5 100644 --- a/jscomp/test/test_external.ml +++ b/jscomp/test/test_external.ml @@ -6,6 +6,13 @@ external (~~) : 'a -> 'b = "%identity" type document external doc : unit -> document = "" [@@js.call "document"] external alert : string -> unit = "" [@@js.call "alert"] + +type v = int -> int +external f : string -> v = "x" [@@js.call "ff"] + + let xx = doc () let () = alert "hehha" + +let b = f "x" 3 diff --git a/jscomp/test/test_ffi.js b/jscomp/test/test_ffi.js index 64679936b6..5792b6ad22 100644 --- a/jscomp/test/test_ffi.js +++ b/jscomp/test/test_ffi.js @@ -1,10 +1,9 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_curry = require("../runtime/caml_curry"); function v(u) { - Caml_curry.app1(console.log, u); + console.log(u); return u; } diff --git a/jscomp/test/test_js_ffi.js b/jscomp/test/test_js_ffi.js index 539b07669c..99c55b7578 100644 --- a/jscomp/test/test_js_ffi.js +++ b/jscomp/test/test_js_ffi.js @@ -1,11 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_curry = require("../runtime/caml_curry"); -var $$String = require("../stdlib/string"); +var $$String = require("../stdlib/string"); function v() { - return Caml_curry.app1(t, [ + return t([ 0, $$String.compare ]); diff --git a/jscomp/test/test_react.js b/jscomp/test/test_react.js index 7eb39bbc9e..7bdd258af0 100644 --- a/jscomp/test/test_react.js +++ b/jscomp/test/test_react.js @@ -10,13 +10,13 @@ Caml_curry.app1(console.log, "hey"); Caml_curry.app1(doc.getElementById, "haha"); -var v = Caml_curry.app1(console.log, 32); +var v = console.log(32); -Caml_curry.app2(ReactDom.render, Caml_curry.app1(React.createClass, { +ReactDom.render(React.createClass({ "render": function () { - return Caml_curry.app4(React.DOM.div, { + return React.DOM.div({ "alt": "pic" - }, Caml_curry.app2(React.DOM.h1, null, "hello react"), Caml_curry.app2(React.DOM.h2, null, "type safe!"), Caml_curry.app2(React.DOM.h3, null, "type safe!")); + }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!"), React.DOM.h3(null, "type safe!")); } }), Caml_curry.app1(document.getElementById, "hi")); diff --git a/jscomp/test/test_scope.js b/jscomp/test/test_scope.js index 6cf7206f1c..f7d577426d 100644 --- a/jscomp/test/test_scope.js +++ b/jscomp/test/test_scope.js @@ -1,11 +1,10 @@ // Generated CODE, PLEASE EDIT WITH CARE 'use strict'; -var Caml_curry = require("../runtime/caml_curry"); -var h = Caml_curry.app1(uuu.x, 3); +var h = uuu.x(3); -var hh = Caml_curry.app1(x, 3); +var hh = x(3); function f(x, y) { return x + y; diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index b7b20b4f5b..3b76f86b4f 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -140,9 +140,9 @@ function find(x, _param) { } function timing(label, f) { - Caml_curry.app1(console.time, label); + console.time(label); Caml_curry.app1(f, /* () */0); - return Caml_curry.app1(console.timeEnd, label); + return console.timeEnd(label); } function assertion_test() { From 9d60645a13d8d6a869cd7ac4ce35ebfe03d0a7df Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Sun, 7 Feb 2016 21:31:47 -0500 Subject: [PATCH 4/5] fix #83 tail call with same arguments --- .gitignore | 1 + jscomp/compiler.mllib | 2 +- jscomp/config_util.ml | 2 +- jscomp/ext_log.ml | 41 ++-- jscomp/ext_log.mli | 26 +-- jscomp/js_dump.ml | 115 ++++++---- jscomp/js_dump.mli | 10 +- jscomp/js_helper.ml | 2 +- jscomp/js_helper.mli | 3 +- jscomp/js_output.ml | 2 + jscomp/js_output.mli | 2 + jscomp/js_pass_debug.ml | 40 ++++ jscomp/js_pass_debug.mli | 21 ++ jscomp/js_pass_flatten_and_mark_dead.ml | 2 +- jscomp/js_program_loader.ml | 2 +- jscomp/lam_compile.ml | 66 +++--- jscomp/lam_compile_external_call.ml | 2 +- jscomp/lam_compile_group.ml | 9 +- jscomp/lam_pass_collect.ml | 4 +- jscomp/lam_pass_remove_alias.ml | 16 +- jscomp/runtime/caml_array.js | 4 + jscomp/runtime/caml_curry.js | 2 + jscomp/runtime/caml_oo.js | 2 + jscomp/stdlib/arg.js | 4 + jscomp/stdlib/array.js | 16 ++ jscomp/stdlib/buffer.js | 18 ++ jscomp/stdlib/bytes.js | 4 + jscomp/stdlib/camlinternalFormat.js | 288 +++++++++++++++--------- jscomp/stdlib/camlinternalOO.js | 12 + jscomp/stdlib/filename.js | 16 ++ jscomp/stdlib/format.js | 10 +- jscomp/stdlib/genlex.js | 30 ++- jscomp/stdlib/hashtbl.js | 26 +++ jscomp/stdlib/list.js | 72 ++++++ jscomp/stdlib/map.js | 24 ++ jscomp/stdlib/parsing.js | 22 +- jscomp/stdlib/pervasives.js | 12 + jscomp/stdlib/printexc.js | 4 + jscomp/stdlib/queue.js | 6 + jscomp/stdlib/random.js | 21 +- jscomp/stdlib/scanf.js | 89 ++++++-- jscomp/stdlib/set.js | 28 +++ jscomp/stdlib/sort.js | 6 + jscomp/stdlib/stream.js | 19 +- jscomp/stdlib/string.js | 2 + jscomp/stdlib/weak.js | 46 ++++ jscomp/test/.depend | 8 + jscomp/test/a_scope_bug.js | 2 + jscomp/test/arith_lexer.js | 6 +- jscomp/test/array_test.js | 2 + jscomp/test/bdd.js | 13 +- jscomp/test/cps_test.js | 2 + jscomp/test/demo.js | 6 +- jscomp/test/demo_page.js | 2 +- jscomp/test/ext_filename.js | 4 + jscomp/test/ext_list.js | 26 +++ jscomp/test/ext_string.js | 14 ++ jscomp/test/fib.js | 2 + jscomp/test/format_regression.d.ts | 7 + jscomp/test/format_regression.js | 85 +++++++ jscomp/test/format_regression.ml | 41 ++++ jscomp/test/inline_edge_cases.js | 8 + jscomp/test/inline_regression_test.js | 4 + jscomp/test/int_map.js | 24 ++ jscomp/test/lexer_test.js | 2 + jscomp/test/loop_regression_test.d.ts | 3 + jscomp/test/loop_regression_test.js | 51 +++++ jscomp/test/loop_regression_test.ml | 14 ++ jscomp/test/map_test.js | 8 + jscomp/test/number_lexer.js | 38 ++-- jscomp/test/printf_test.d.ts | 1 + jscomp/test/printf_test.js | 63 ++++-- jscomp/test/printf_test.ml | 3 +- jscomp/test/qcc.js | 46 +++- jscomp/test/rec_value_test.js | 4 + jscomp/test/simple_lexer_test.js | 2 + jscomp/test/small_inline_test.js | 5 + jscomp/test/string_test.js | 4 + jscomp/test/tailcall_inline_test.js | 2 + jscomp/test/test.mllib | 4 +- jscomp/test/test_ari.js | 2 + jscomp/test/test_cps.js | 2 + jscomp/test/test_fib.js | 2 + jscomp/test/test_for_map.js | 24 ++ jscomp/test/test_inline_map.js | 2 + jscomp/test/test_inline_map2.js | 4 + jscomp/test/test_internalOO.js | 76 +++++++ jscomp/test/test_list.js | 72 ++++++ jscomp/test/test_map_find.js | 4 + jscomp/test/test_order_tailcall.js | 29 ++- jscomp/test/test_per.js | 12 + jscomp/test/test_react.js | 2 +- jscomp/test/test_seq.js | 2 + jscomp/test/test_set.js | 28 +++ jscomp/test/test_simple_tailcall.js | 3 + jscomp/test/test_string_map.js | 2 + jscomp/test/ticker.js | 30 +++ 97 files changed, 1610 insertions(+), 343 deletions(-) create mode 100644 jscomp/js_pass_debug.ml create mode 100644 jscomp/js_pass_debug.mli create mode 100644 jscomp/test/format_regression.d.ts create mode 100644 jscomp/test/format_regression.js create mode 100644 jscomp/test/format_regression.ml create mode 100644 jscomp/test/loop_regression_test.d.ts create mode 100644 jscomp/test/loop_regression_test.js create mode 100644 jscomp/test/loop_regression_test.ml diff --git a/.gitignore b/.gitignore index fb77467b4a..ae67372add 100644 --- a/.gitignore +++ b/.gitignore @@ -48,5 +48,6 @@ ocaml/man jscomp/bench/*.js *.bak .vscode +*.jsx osc jscomp/pre_load.js \ No newline at end of file diff --git a/jscomp/compiler.mllib b/jscomp/compiler.mllib index 82fcdc5e67..d0aaae6d19 100644 --- a/jscomp/compiler.mllib +++ b/jscomp/compiler.mllib @@ -73,7 +73,7 @@ js_fun_env js_pass_flatten_and_mark_dead js_pass_scope js_call_info - +js_pass_debug js_of_lam_float_record js_of_lam_record js_of_lam_tuple diff --git a/jscomp/config_util.ml b/jscomp/config_util.ml index f97e9c7f14..d573caa69d 100644 --- a/jscomp/config_util.ml +++ b/jscomp/config_util.ml @@ -44,7 +44,7 @@ let find_cmj file = -> Lazy.force v | exception Not_found -> - Ext_log.warn __LOC__ "@[%s not found @]@." file ; + Ext_log.warn __LOC__ "@[%s not found @]" file ; Js_cmj_format.dummy (); (* FIXME *) end end diff --git a/jscomp/ext_log.ml b/jscomp/ext_log.ml index 13e07ade56..b9f4d520ba 100644 --- a/jscomp/ext_log.ml +++ b/jscomp/ext_log.ml @@ -21,41 +21,42 @@ -type ('a,'b) logging = - ('a -> 'b, Format.formatter, unit, unit, unit, unit) format6 -> 'a -> 'b -let err str f v = - Format.fprintf Format.err_formatter ("%s " ^^ f) str v +type 'a logging = ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a -let ierr b str f v = +let err str f = + Format.fprintf Format.err_formatter ("%s " ^^ f) str + +let ierr b str f = if b then - Format.fprintf Format.err_formatter ("%s " ^^ f) str v + Format.fprintf Format.err_formatter ("%s " ^^ f) str else - Format.ifprintf Format.err_formatter ("%s " ^^ f) str v + Format.ifprintf Format.err_formatter ("%s " ^^ f) str -let warn str f v = - Format.fprintf Format.err_formatter ("WARN: %s " ^^ f) str v +let warn str f = + Format.fprintf Format.err_formatter ("WARN: %s " ^^ f ^^ "@.") str -let iwarn b str f v = +let iwarn b str f = if b then - Format.fprintf Format.err_formatter ("WARN: %s " ^^ f) str v + Format.fprintf Format.err_formatter ("WARN: %s " ^^ f) str else - Format.ifprintf Format.err_formatter ("WARN: %s " ^^ f) str v + Format.ifprintf Format.err_formatter ("WARN: %s " ^^ f) str -let dwarn str f v = +(* TODO: add {[@.]} later for all *) +let dwarn str f = if Lam_current_unit.is_same_file () then - Format.fprintf Format.err_formatter ("WARN: %s " ^^ f) str v + Format.fprintf Format.err_formatter ("WARN: %s " ^^ f ^^ "@.") str else - Format.ifprintf Format.err_formatter ("WARN: %s " ^^ f) str v + Format.ifprintf Format.err_formatter ("WARN: %s " ^^ f ^^ "@.") str -let info str f v = - Format.fprintf Format.err_formatter ("INFO: %s " ^^ f) str v +let info str f = + Format.fprintf Format.err_formatter ("INFO: %s " ^^ f) str -let iinfo b str f v = +let iinfo b str f = if b then - Format.fprintf Format.err_formatter ("INFO: %s " ^^ f) str v + Format.fprintf Format.err_formatter ("INFO: %s " ^^ f) str else - Format.fprintf Format.err_formatter ("INFO: %s " ^^ f) str v + Format.fprintf Format.err_formatter ("INFO: %s " ^^ f) str diff --git a/jscomp/ext_log.mli b/jscomp/ext_log.mli index b329712dee..5741fbec04 100644 --- a/jscomp/ext_log.mli +++ b/jscomp/ext_log.mli @@ -29,18 +29,14 @@ *) -type ('a,'b) logging = ('a -> 'b, Format.formatter, unit, unit, unit, unit) format6 -> 'a -> 'b - -(* FIXM: below does not work - {[ - err __LOC__ "hi" - ]} - -*) -val err : string -> ('a,'b) logging -val ierr : bool -> string -> ('a,'b) logging -val warn : string -> ('a,'b) logging -val iwarn : bool -> string -> ('a,'b) logging -val dwarn : string -> ('a,'b) logging -val info : string -> ('a,'b) logging -val iinfo : bool -> string -> ('a,'b) logging + +type 'a logging = ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a + + +val err : string -> 'a logging +val ierr : bool -> string -> 'a logging +val warn : string -> 'a logging +val iwarn : bool -> string -> 'a logging +val dwarn : string -> 'a logging +val info : string -> 'a logging +val iinfo : bool -> string -> 'a logging diff --git a/jscomp/js_dump.ml b/jscomp/js_dump.ml index 907d8630ae..610ec2b6d2 100644 --- a/jscomp/js_dump.ml +++ b/jscomp/js_dump.ml @@ -1317,46 +1317,46 @@ let exports cxt f (idents : Ident.t list) = outer_cxt -let node_program f ( {program ; modules ; } : J.deps_program) = - let cxt = Ext_pp_scope.empty in - (* Node style *) - let requires cxt f (modules : (Ident.t * string) list ) = - P.newline f ; - (* the context used to print the following program *) - let outer_cxt, reversed_list, margin = - List.fold_left - (fun (cxt, acc, len) (id,s) -> - let str, cxt = str_of_ident cxt id in - cxt, ((str,s) :: acc), (max len (String.length str)) - ) - (cxt, [], 0) modules in - P.force_newline f ; - Ext_list.rev_iter (fun (s,file) -> - P.string f L.var; - P.space f ; - P.string f s ; - P.nspace f (margin - String.length s + 1) ; - P.string f L.eq; - P.space f; - P.string f L.require; - P.paren_group f 0 @@ (fun _ -> - pp_string f ~utf:true ~quote:(best_string_quote s) file ); - semi f ; - P.newline f ; - ) reversed_list; - outer_cxt - in - - let cxt = requires cxt f modules in +(* Node style *) +let requires cxt f (modules : (Ident.t * string) list ) = + P.newline f ; + (* the context used to print the following program *) + let outer_cxt, reversed_list, margin = + List.fold_left + (fun (cxt, acc, len) (id,s) -> + let str, cxt = str_of_ident cxt id in + cxt, ((str,s) :: acc), (max len (String.length str)) + ) + (cxt, [], 0) modules in + P.force_newline f ; + Ext_list.rev_iter (fun (s,file) -> + P.string f L.var; + P.space f ; + P.string f s ; + P.nspace f (margin - String.length s + 1) ; + P.string f L.eq; + P.space f; + P.string f L.require; + P.paren_group f 0 @@ (fun _ -> + pp_string f ~utf:true ~quote:(best_string_quote s) file ); + semi f ; + P.newline f ; + ) reversed_list; + outer_cxt +let program f cxt ( x : J.program ) = let () = P.force_newline f in - let cxt = statement_list true cxt f program.block in + let cxt = statement_list true cxt f x.block in let () = P.force_newline f in - exports cxt f program.exports + exports cxt f x.exports +let node_program f ( x : J.deps_program) = + let cxt = requires ( Ext_pp_scope.empty) f x.modules in + program f cxt x.program + let amd_program f - ( {program ; modules ; _} : J.deps_program) + ( x : J.deps_program) = P.newline f ; let cxt = Ext_pp_scope.empty in @@ -1369,7 +1369,7 @@ let amd_program f P.string f L.comma ; P.space f; pp_string f ~utf:true ~quote:(best_string_quote s) s; - ) modules ; + ) x.modules ; P.string f "]"; P.string f L.comma; P.newline f; @@ -1382,33 +1382,30 @@ let amd_program f P.string f L.comma; P.space f ; ident cxt f id - ) cxt modules + ) cxt x.modules in P.string f ")"; - P.brace_vgroup f 1 @@ (fun _ -> + let v = P.brace_vgroup f 1 @@ (fun _ -> let () = P.string f L.strict_directive in - let () = P.newline f in - let cxt = statement_list true cxt f program.block in - (* FIXME AMD : use {[ function xx ]} or {[ var x = function ..]} *) - P.newline f; - P.force_newline f; - ignore (exports cxt f program.exports)); + program f cxt x.program + ) in P.string f ")"; + v ;; -let pp_program ( program : J.deps_program) (f : Ext_pp.t) = +let pp_deps_program ( program : J.deps_program) (f : Ext_pp.t) = begin P.string f "// Generated CODE, PLEASE EDIT WITH CARE"; P.newline f; P.string f L.strict_directive; P.newline f ; - (match Js_config.get_env () with + ignore (match Js_config.get_env () with | Browser -> - ignore (node_program f program) + (node_program f program) | NodeJS -> begin match Sys.getenv "OCAML_AMD_MODULE" with | exception Not_found -> - ignore (node_program f program) + (node_program f program) (* amd_program f program *) | _ -> amd_program f program end ) ; @@ -1420,7 +1417,25 @@ let pp_program ( program : J.deps_program) (f : Ext_pp.t) = P.newline f; P.flush f () end -let dump_program - (program : J.deps_program) + +let dump_program (x : J.program) oc = + ignore (program (P.from_channel oc) Ext_pp_scope.empty x ) + +let dump_deps_program + x (oc : out_channel) = - pp_program program (P.from_channel oc) + pp_deps_program x (P.from_channel oc) + +let string_of_block block + = + let buffer = Buffer.create 50 in + begin + let f = P.from_buffer buffer in + let _scope = statement_list true Ext_pp_scope.empty f block in + P.flush f (); + Buffer.contents buffer + end + + + + diff --git a/jscomp/js_dump.mli b/jscomp/js_dump.mli index 1bfc5691e1..558528b5c5 100644 --- a/jscomp/js_dump.mli +++ b/jscomp/js_dump.mli @@ -25,6 +25,12 @@ (** Print JS IR to vanilla Javascript code *) -val pp_program : J.deps_program -> Ext_pp.t -> unit -val dump_program : J.deps_program -> out_channel -> unit + + +val dump_deps_program : J.deps_program -> out_channel -> unit + +(** 2 functions Only used for debugging *) +val string_of_block : J.block -> string + +val dump_program : J.program -> out_channel -> unit diff --git a/jscomp/js_helper.ml b/jscomp/js_helper.ml index ac7c534497..a66d328ded 100644 --- a/jscomp/js_helper.ml +++ b/jscomp/js_helper.ml @@ -1175,7 +1175,7 @@ module Stmt = struct (* TODO: actually, only loops can be labelled *) - let continue ?comment label : t = + let continue ?comment ?(label="") unit : t = { statement_desc = J.Continue label; comment; diff --git a/jscomp/js_helper.mli b/jscomp/js_helper.mli index c203a7cbf0..fc9349bda5 100644 --- a/jscomp/js_helper.mli +++ b/jscomp/js_helper.mli @@ -298,6 +298,7 @@ module Stmt : sig val break : ?comment:string -> unit -> t - val continue : ?comment:string -> J.label -> t + (** if [label] is not set, it will default to empty *) + val continue : ?comment:string -> ?label:J.label -> unit -> t end diff --git a/jscomp/js_output.ml b/jscomp/js_output.ml index f90ed7a987..f349e6d54b 100644 --- a/jscomp/js_output.ml +++ b/jscomp/js_output.ml @@ -166,3 +166,5 @@ end let concat (xs : t list) : t = List.fold_right (fun x acc -> append x acc) xs dummy +let to_string x = + Js_dump.string_of_block (to_block x) diff --git a/jscomp/js_output.mli b/jscomp/js_output.mli index 8b1c9d3692..a5947ed5f1 100644 --- a/jscomp/js_output.mli +++ b/jscomp/js_output.mli @@ -63,3 +63,5 @@ val handle_block_return : Lam_compile_defs.st -> Lam_compile_defs.return_type -> Lambda.lambda -> J.block -> J.expression -> t val concat : t list -> t + +val to_string : t -> string diff --git a/jscomp/js_pass_debug.ml b/jscomp/js_pass_debug.ml new file mode 100644 index 0000000000..bb715bdb5b --- /dev/null +++ b/jscomp/js_pass_debug.ml @@ -0,0 +1,40 @@ +(* 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 *) + +let log_counter = ref 0 + +let dump (prog : J.program) = + begin + let () = + if Js_config.get_env () != Browser + (* TODO: when no [Browser] detection, it will go through.. bug in js_of_ocaml? *) + && Lam_current_unit.is_same_file () + then + begin + incr log_counter ; + Ext_pervasives.with_file_as_chan + (Ext_filename.chop_extension ~loc:__LOC__ (Lam_current_unit.get_file()) ^ + (Printf.sprintf ".%02d.jsx" !log_counter) + ) (fun chan -> Js_dump.dump_program prog chan ) + end in + prog + end + + diff --git a/jscomp/js_pass_debug.mli b/jscomp/js_pass_debug.mli new file mode 100644 index 0000000000..5bfe95911f --- /dev/null +++ b/jscomp/js_pass_debug.mli @@ -0,0 +1,21 @@ +(* 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 dump : J.program -> J.program diff --git a/jscomp/js_pass_flatten_and_mark_dead.ml b/jscomp/js_pass_flatten_and_mark_dead.ml index 840680f62d..1ba1f0f29d 100644 --- a/jscomp/js_pass_flatten_and_mark_dead.ml +++ b/jscomp/js_pass_flatten_and_mark_dead.ml @@ -88,7 +88,7 @@ let mark_dead = object (self) (** check [camlinternlFormat,box_type] inlined twice FIXME: seems we have redeclared identifiers *) - Ext_log.warn __LOC__ "@[%s$%d in %s@]@." ident.name ident.stamp name + Ext_log.warn __LOC__ "@[%s$%d in %s@]" ident.name ident.stamp name (* assert false *) | exception Not_found -> (* First time *) Hashtbl.add ident_use_stats ident (`Info ident_info); diff --git a/jscomp/js_program_loader.ml b/jscomp/js_program_loader.ml index 2189aa4b3a..caa3d8feb0 100644 --- a/jscomp/js_program_loader.ml +++ b/jscomp/js_program_loader.ml @@ -62,7 +62,7 @@ let string_of_module_id (x : module_id) : string = begin match Config_util.find file with (* for some primitive files, no cmj support *) | exception Not_found -> - Ext_log.warn __LOC__ "@[%s not found in search path - while compiling %s @] @." + Ext_log.warn __LOC__ "@[%s not found in search path - while compiling %s @] " file !Location.input_name ; Printf.sprintf "%s" (String.uncapitalize id.name) diff --git a/jscomp/lam_compile.ml b/jscomp/lam_compile.ml index ca9bd1fa8f..5b9be8e13c 100644 --- a/jscomp/lam_compile.ml +++ b/jscomp/lam_compile.ml @@ -355,30 +355,36 @@ and http://caml.inria.fr/pub/ml-archives/caml-list/2005/02/fe9bc4e23e6dc8c932c8ab34240ff195.en.html *) - Js_output.of_block (* ~finished:true *) - ( - (List.concat args_code @ - ( - let (_,assigned_params,new_params) = - List.fold_left2 (fun (i,assigns,new_params) param (arg : J.expression) -> - match arg with - | {expression_desc = Var (Id x); _} when Ident.same x param -> - (i + 1, assigns, new_params) - | _ -> - let new_param, m = - match Ident_map.find param ret.new_params with - | exception Not_found -> - ret.immutable_mask.(i)<- false; - let v = Ext_ident.create ("_"^param.Ident.name) in - v, (Ident_map.add param v new_params) - | v -> v, new_params in - (i+1, (new_param, arg) :: assigns, m) - ) (0, [], Ident_map.empty) params args in - let () = ret.new_params <- Ident_map.(merge_disjoint new_params ret.new_params) in - assigned_params |> List.map (fun (param, arg) -> S.assign param arg)) - (* @ *) - (* [S.continue label] *) - )) + (* TODO: use [fold]*) + let block = List.concat args_code @ + ( + let (_,assigned_params,new_params) = + List.fold_left2 (fun (i,assigns,new_params) param (arg : J.expression) -> + match arg with + | {expression_desc = Var (Id x); _} when Ident.same x param -> + (i + 1, assigns, new_params) + | _ -> + let new_param, m = + match Ident_map.find param ret.new_params with + | exception Not_found -> + ret.immutable_mask.(i)<- false; + let v = Ext_ident.create ("_"^param.Ident.name) in + v, (Ident_map.add param v new_params) + | v -> v, new_params in + (i+1, (new_param, arg) :: assigns, m) + ) (0, [], Ident_map.empty) params args in + let () = ret.new_params <- Ident_map.(merge_disjoint new_params ret.new_params) in + assigned_params |> List.map (fun (param, arg) -> S.assign param arg)) + @ + [S.continue ()(* label *)] + (* Note true and continue needed to be handled together*) + in + begin + (* Ext_log.dwarn __LOC__ "size : %d" (List.length block); *) + Js_output.of_block ~finished:True block + end + + (* match assigned_params with *) (* | [] -> [] *) @@ -521,7 +527,15 @@ and compile_lambda {cxt with st = EffectCall; should_return = False} l1 in let output_l2 = compile_lambda cxt l2 in - output_l1 ++ output_l2 + let result = output_l1 ++ output_l2 in + (* let () = *) + (* Ext_log.dwarn __LOC__ *) + (* "@ @[l1:%a@ js-l1(%d):%s@ l2:@ %a@ js-l2(%d):%s@ js-l:@ %s@]" *) + (* Printlambda.lambda l1 (List.length output_l1.block) (Js_output.to_string output_l1) *) + (* Printlambda.lambda l2 (List.length output_l2.block) (Js_output.to_string output_l2) *) + (* (Js_output.to_string result ) in *) + result + (* begin match cxt.st, cxt.should_return with *) (* | NeedValue, False -> *) @@ -593,7 +607,7 @@ and {block = []; value = Some out1}, {block = []; value = Some out2} -> Js_output.make [S.return (E.econd e out1 out2)] ~finished:True - + (* see PR#83 *) | EffectCall, False , {block = []; value = Some out1}, {block = []; value = Some out2} -> begin diff --git a/jscomp/lam_compile_external_call.ml b/jscomp/lam_compile_external_call.ml index b5276432b9..54d21b5e9a 100644 --- a/jscomp/lam_compile_external_call.ml +++ b/jscomp/lam_compile_external_call.ml @@ -371,7 +371,7 @@ let translate let [@warning"-8"] (_return_type, self_type::arg_types ) = Type_util.list_of_arrow ty in let args = Ext_list.flat_map2_last (ocaml_to_js js_splice) arg_types args in - E.call (E.dot self name) args + E.call ~info:{arity=Full} (E.dot self name) args | _ -> assert false end diff --git a/jscomp/lam_compile_group.ml b/jscomp/lam_compile_group.ml index 64a6265bd3..1a67cb3b4e 100644 --- a/jscomp/lam_compile_group.ml +++ b/jscomp/lam_compile_group.ml @@ -160,7 +160,8 @@ let compile ~filename non_export env _sigs lam = in let () = Translmod.reset () in (* To make toplevel happy - reentrant for js-demo *) let () = Lam_compile_env.reset () in - let _d = Lam_util.dump env filename in + let _d = Lam_util.dump env filename in + let _j = Js_pass_debug.dump in let lam = _d lam in let lam = Lam_group.deep_flatten lam in let lam = _d lam in @@ -312,7 +313,9 @@ let compile ~filename non_export env _sigs lam = body in js + |> _j |> Js_pass_flatten.program + |> _j |> Js_inline_and_eliminate.inline_and_shake |> Js_pass_flatten_and_mark_dead.program @@ -354,10 +357,10 @@ let lambda_as_module (lam : Lambda.lambda) = begin Lam_current_unit.set_file filename ; - Lam_current_unit.iset_debug_file "ari_regress_test.ml"; + Lam_current_unit.iset_debug_file "format_regression.ml"; Ext_pervasives.with_file_as_chan (Ext_filename.chop_extension ~loc:__LOC__ filename ^ ".js") - (fun chan -> Js_dump.dump_program (compile ~filename false env sigs lam) chan) + (fun chan -> Js_dump.dump_deps_program (compile ~filename false env sigs lam) chan) end (* We can use {!Env.current_unit = "Pervasives"} to tell if it is some specific module, We need handle some definitions in standard libraries in a special way, most are io specific, diff --git a/jscomp/lam_pass_collect.ml b/jscomp/lam_pass_collect.ml index 30d9ade549..6efb3374a5 100644 --- a/jscomp/lam_pass_collect.ml +++ b/jscomp/lam_pass_collect.ml @@ -24,7 +24,7 @@ let annotate (meta : Lam_stats.meta) rec_flag (k:Ident.t) (v : Lam_stats.function_arities) lambda = - (* Ext_log.dwarn __LOC__ "%s/%d@." k.name k.stamp; *) + (* Ext_log.dwarn __LOC__ "%s/%d" k.name k.stamp; *) match Hashtbl.find meta.ident_tbl k with | exception Not_found -> Hashtbl.add meta.ident_tbl k (Function {kind = NA; arity = v; lambda; rec_flag}) @@ -90,7 +90,7 @@ let collect_helper (meta : Lam_stats.meta) (lam : Lambda.lambda) = List.iter (fun p -> Hashtbl.add meta.ident_tbl p Parameter ) params; let arity = Lam_stats_util.get_arity meta lam in - (* Ext_log.dwarn __LOC__ "%s/%d : %a : %a function collected@." *) + (* Ext_log.dwarn __LOC__ "%s/%d : %a : %a function collected" *) (* ident.name ident.stamp *) (* Printlambda.lambda lam *) (* Lam_stats_util.pp_arities arity *) diff --git a/jscomp/lam_pass_remove_alias.ml b/jscomp/lam_pass_remove_alias.ml index 039b65541f..ad80cf5eaf 100644 --- a/jscomp/lam_pass_remove_alias.ml +++ b/jscomp/lam_pass_remove_alias.ml @@ -101,7 +101,7 @@ let simplify_alias *) | Lapply((Lvar v as l1), args, info) -> (* Check info for always inlining *) - (* Ext_log.dwarn __LOC__ "%s/%d@." v.name v.stamp; *) + (* Ext_log.dwarn __LOC__ "%s/%d" v.name v.stamp; *) begin match Hashtbl.find meta.ident_tbl v with @@ -121,7 +121,7 @@ let simplify_alias (* Check: recursive applying may result in non-termination *) begin - (* Ext_log.dwarn __LOC__ "beta .. %s/%d@." v.name v.stamp ; *) + (* Ext_log.dwarn __LOC__ "beta .. %s/%d" v.name v.stamp ; *) simpl (Lam_beta_reduce.propogate_beta_reduce meta params body args) end else @@ -140,13 +140,13 @@ let simplify_alias then if rec_flag = Rec then begin - (* Ext_log.dwarn __LOC__ "beta rec.. %s/%d@." v.name v.stamp ; *) + (* Ext_log.dwarn __LOC__ "beta rec.. %s/%d" v.name v.stamp ; *) (* Lam_beta_reduce.propogate_beta_reduce meta params body args *) Lam_beta_reduce.propogate_beta_reduce_with_map meta param_map params body args end else begin - (* Ext_log.dwarn __LOC__ "beta nonrec..[%d] [%a] %s/%d@." *) + (* Ext_log.dwarn __LOC__ "beta nonrec..[%d] [%a] %s/%d" *) (* (List.length args) *) (* Printlambda.lambda body *) (* v.name v.stamp ; *) @@ -157,24 +157,24 @@ let simplify_alias Lapply ( simpl l1, List.map simpl args, info) else begin - (* Ext_log.dwarn __LOC__ "%s/%d: %d @." *) + (* Ext_log.dwarn __LOC__ "%s/%d: %d " *) (* v.name v.stamp lam_size *) (* ; *) Lapply ( simpl l1, List.map simpl args, info) end else begin - (* Ext_log.dwarn __LOC__ "%d vs %d @." (List.length args) (List.length params); *) + (* Ext_log.dwarn __LOC__ "%d vs %d " (List.length args) (List.length params); *) Lapply ( simpl l1, List.map simpl args, info) end | _ -> begin - (* Ext_log.dwarn __LOC__ "%s/%d -- no source @." v.name v.stamp; *) + (* Ext_log.dwarn __LOC__ "%s/%d -- no source " v.name v.stamp; *) Lapply ( simpl l1, List.map simpl args, info) end | exception Not_found -> - (* Ext_log.dwarn __LOC__ "%s/%d -- not found @." v.name v.stamp; *) + (* Ext_log.dwarn __LOC__ "%s/%d -- not found " v.name v.stamp; *) Lapply ( simpl l1, List.map simpl args, info) end diff --git a/jscomp/runtime/caml_array.js b/jscomp/runtime/caml_array.js index 2db80669f6..d541f78f71 100644 --- a/jscomp/runtime/caml_array.js +++ b/jscomp/runtime/caml_array.js @@ -21,6 +21,8 @@ function len(_acc, _l) { if (l) { _l = l[2]; _acc = l[1].length + acc; + continue ; + } else { return acc; @@ -44,6 +46,8 @@ function fill(arr, _i, _l) { }; _l = l[2]; _i = k; + continue ; + } else { return /* () */0; diff --git a/jscomp/runtime/caml_curry.js b/jscomp/runtime/caml_curry.js index 85b19d1ff3..e98d236cc9 100644 --- a/jscomp/runtime/caml_curry.js +++ b/jscomp/runtime/caml_curry.js @@ -14,6 +14,8 @@ function curry(_f, _args) { if (d < 0) { _args = Caml_array.caml_array_sub(args, arity, -d); _f = f.apply(null, Caml_array.caml_array_sub(args, 0, arity)); + continue ; + } else { return (function(f,args){ diff --git a/jscomp/runtime/caml_oo.js b/jscomp/runtime/caml_oo.js index 4db4a33542..5b35dc6f78 100644 --- a/jscomp/runtime/caml_oo.js +++ b/jscomp/runtime/caml_oo.js @@ -34,6 +34,8 @@ function caml_get_public_method(obj, tag, cacheid) { } else { _i = i - 2; + continue ; + } }; }; diff --git a/jscomp/stdlib/arg.js b/jscomp/stdlib/arg.js index d5bc66fda4..aa429419b3 100644 --- a/jscomp/stdlib/arg.js +++ b/jscomp/stdlib/arg.js @@ -40,6 +40,8 @@ function assoc3(x, _l) { } else { _l = l[2]; + continue ; + } } else { @@ -824,6 +826,8 @@ function second_word(s) { } else if (s[n] === " ") { _n = n + 1; + continue ; + } else { return n; diff --git a/jscomp/stdlib/array.js b/jscomp/stdlib/array.js index d6674fea67..33ca5cd9e1 100644 --- a/jscomp/stdlib/array.js +++ b/jscomp/stdlib/array.js @@ -145,6 +145,8 @@ function to_list(a) { res ]; _i = i - 1; + continue ; + } }; } @@ -156,6 +158,8 @@ function list_length(_accu, _param) { if (param) { _param = param[2]; _accu = accu + 1; + continue ; + } else { return accu; @@ -175,6 +179,8 @@ function of_list(l) { a[i] = param[1]; _param = param[2]; _i = i + 1; + continue ; + } else { return a; @@ -246,6 +252,8 @@ function sort(cmp, a) { if (Caml_curry.app2(cmp, a[j], e$1) > 0) { a[i$1] = a[j]; _i = j; + continue ; + } else { a[i$1] = e$1; @@ -272,6 +280,8 @@ function sort(cmp, a) { var j = maxson(l$1, i$1); a[i$1] = a[j]; _i = j; + continue ; + }; } catch (exn){ @@ -303,6 +313,8 @@ function sort(cmp, a) { a[i] = a[father]; if (father > 0) { _i = father; + continue ; + } else { a[0] = e; @@ -359,6 +371,8 @@ function stable_sort(cmp, a) { _d = d + 1; _s1 = a[i1$1]; _i1 = i1$1; + continue ; + } else { return blit(src2, i2, dst, d + 1, src2r - i2); @@ -371,6 +385,8 @@ function stable_sort(cmp, a) { _d = d + 1; _s2 = src2[i2$1]; _i2 = i2$1; + continue ; + } else { return blit(a, i1, dst, d + 1, src1r - i1); diff --git a/jscomp/stdlib/buffer.js b/jscomp/stdlib/buffer.js index 2b9ce67eef..6bd9613496 100644 --- a/jscomp/stdlib/buffer.js +++ b/jscomp/stdlib/buffer.js @@ -192,11 +192,15 @@ function advance_to_closing(opening, closing, k, s, start) { else if (s.charCodeAt(i) === opening) { _i = i + 1; _k = k$1 + 1; + continue ; + } else if (s.charCodeAt(i) === closing) { if (k$1) { _i = i + 1; _k = k$1 - 1; + continue ; + } else { return i; @@ -204,6 +208,8 @@ function advance_to_closing(opening, closing, k, s, start) { } else { _i = i + 1; + continue ; + } }; } @@ -251,6 +257,8 @@ function advance_to_non_alpha(s, start) { } if (exit === 1) { _i = i + 1; + continue ; + } } @@ -308,21 +316,29 @@ function add_substitute(b, f, s) { add_char(b, current); _i = i + 1; _previous = /* " " */32; + continue ; + } else if (current !== 92) { add_char(b, current); _i = i + 1; _previous = current; + continue ; + } else { _i = i + 1; _previous = current; + continue ; + } } else if (previous === /* "\\" */92) { add_char(b, current); _i = i + 1; _previous = /* " " */32; + continue ; + } else { var j = i + 1; @@ -330,6 +346,8 @@ function add_substitute(b, f, s) { add_string(b, Caml_curry.app1(f, match[1])); _i = match[2]; _previous = /* " " */32; + continue ; + } } else if (previous === /* "\\" */92) { diff --git a/jscomp/stdlib/bytes.js b/jscomp/stdlib/bytes.js index ecf83a4f26..3090eec47b 100644 --- a/jscomp/stdlib/bytes.js +++ b/jscomp/stdlib/bytes.js @@ -372,6 +372,8 @@ function index_rec(s, lim, _i, c) { } else { _i = i + 1; + continue ; + } }; } @@ -401,6 +403,8 @@ function rindex_rec(s, _i, c) { } else { _i = i - 1; + continue ; + } }; } diff --git a/jscomp/stdlib/camlinternalFormat.js b/jscomp/stdlib/camlinternalFormat.js index 420e0f28f8..cc6dbcc012 100644 --- a/jscomp/stdlib/camlinternalFormat.js +++ b/jscomp/stdlib/camlinternalFormat.js @@ -384,6 +384,8 @@ function bprint_char_set(buf, char_set) { } else { _i = i + 1; + continue ; + } } else { @@ -437,6 +439,8 @@ function bprint_char_set(buf, char_set) { } else { _j = j + 1; + continue ; + } }; } @@ -673,68 +677,68 @@ function bprint_fmtty(buf, _fmtty) { case 0 : buffer_add_string(buf, "%c"); _fmtty = fmtty[1]; - break; - case 1 : + continue ; + case 1 : buffer_add_string(buf, "%s"); _fmtty = fmtty[1]; - break; - case 2 : + continue ; + case 2 : buffer_add_string(buf, "%i"); _fmtty = fmtty[1]; - break; - case 3 : + continue ; + case 3 : buffer_add_string(buf, "%li"); _fmtty = fmtty[1]; - break; - case 4 : + continue ; + case 4 : buffer_add_string(buf, "%ni"); _fmtty = fmtty[1]; - break; - case 5 : + continue ; + case 5 : buffer_add_string(buf, "%Li"); _fmtty = fmtty[1]; - break; - case 6 : + continue ; + case 6 : buffer_add_string(buf, "%f"); _fmtty = fmtty[1]; - break; - case 7 : + continue ; + case 7 : buffer_add_string(buf, "%B"); _fmtty = fmtty[1]; - break; - case 8 : + continue ; + case 8 : buffer_add_string(buf, "%{"); bprint_fmtty(buf, fmtty[1]); buffer_add_string(buf, "%}"); _fmtty = fmtty[2]; - break; - case 9 : + continue ; + case 9 : buffer_add_string(buf, "%("); bprint_fmtty(buf, fmtty[1]); buffer_add_string(buf, "%)"); _fmtty = fmtty[3]; - break; - case 10 : + continue ; + case 10 : buffer_add_string(buf, "%a"); _fmtty = fmtty[1]; - break; - case 11 : + continue ; + case 11 : buffer_add_string(buf, "%t"); _fmtty = fmtty[1]; - break; - case 12 : + continue ; + case 12 : buffer_add_string(buf, "%?"); _fmtty = fmtty[1]; - break; - case 13 : + continue ; + case 13 : buffer_add_string(buf, "%r"); _fmtty = fmtty[1]; - break; - case 14 : + continue ; + case 14 : buffer_add_string(buf, "%_r"); _fmtty = fmtty[1]; - break; - + continue ; + } } }; @@ -766,75 +770,75 @@ function bprint_fmt(buf, fmt) { buffer_add_char(buf, /* "c" */99); _ign_flag = /* false */0; _fmt = fmt$1[1]; - break; - case 1 : + 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]; - break; - case 2 : + continue ; + case 2 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); bprint_padding(buf, fmt$1[1]); buffer_add_char(buf, /* "s" */115); _ign_flag = /* false */0; _fmt = fmt$1[2]; - break; - case 3 : + continue ; + case 3 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); bprint_padding(buf, fmt$1[1]); buffer_add_char(buf, /* "S" */83); _ign_flag = /* false */0; _fmt = fmt$1[2]; - break; - case 4 : + continue ; + case 4 : bprint_int_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3]); _ign_flag = /* false */0; _fmt = fmt$1[4]; - break; - case 5 : + continue ; + case 5 : bprint_altint_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3], /* "l" */108); _ign_flag = /* false */0; _fmt = fmt$1[4]; - break; - case 6 : + continue ; + case 6 : bprint_altint_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3], /* "n" */110); _ign_flag = /* false */0; _fmt = fmt$1[4]; - break; - case 7 : + continue ; + case 7 : bprint_altint_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3], /* "L" */76); _ign_flag = /* false */0; _fmt = fmt$1[4]; - break; - case 8 : + continue ; + case 8 : bprint_float_fmt(buf, ign_flag, fmt$1[1], fmt$1[2], fmt$1[3]); _ign_flag = /* false */0; _fmt = fmt$1[4]; - break; - case 9 : + 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]; - break; - case 10 : + continue ; + case 10 : buffer_add_string(buf, "%!"); _fmt = fmt$1[1]; - break; - case 11 : + continue ; + case 11 : bprint_string_literal(buf, fmt$1[1]); _fmt = fmt$1[2]; - break; - case 12 : + continue ; + case 12 : bprint_char_literal(buf, fmt$1[1]); _fmt = fmt$1[2]; - break; - case 13 : + continue ; + case 13 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); bprint_pad_opt(buf, fmt$1[1]); @@ -844,8 +848,8 @@ function bprint_fmt(buf, fmt) { buffer_add_char(buf, /* "}" */125); _ign_flag = /* false */0; _fmt = fmt$1[3]; - break; - case 14 : + continue ; + case 14 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); bprint_pad_opt(buf, fmt$1[1]); @@ -855,65 +859,65 @@ function bprint_fmt(buf, fmt) { buffer_add_char(buf, /* ")" */41); _ign_flag = /* false */0; _fmt = fmt$1[3]; - break; - case 15 : + 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]; - break; - case 16 : + 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]; - break; - case 17 : + continue ; + case 17 : bprint_string_literal(buf, string_of_formatting_lit(fmt$1[1])); _fmt = fmt$1[2]; - break; - case 18 : + continue ; + case 18 : bprint_string_literal(buf, "@{"); bprint_string_literal(buf, string_of_formatting_gen(fmt$1[1])); _fmt = fmt$1[2]; - break; - case 19 : + 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]; - break; - case 20 : + 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]); _ign_flag = /* false */0; _fmt = fmt$1[3]; - break; - case 21 : + continue ; + case 21 : buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); buffer_add_char(buf, char_of_counter(fmt$1[1])); _ign_flag = /* false */0; _fmt = fmt$1[2]; - break; - case 22 : + 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]; - break; - case 23 : + continue ; + case 23 : var match = param_format_of_ignored_format(fmt$1[1], fmt$1[2]); _ign_flag = /* true */1; _fmt = match[1]; - break; - case 24 : + continue ; + case 24 : for(var _i = 1 ,_i_finish = int_of_custom_arity(fmt$1[1]); _i<= _i_finish; ++_i){ buffer_add_char(buf, /* "%" */37); bprint_ignored_flag(buf, ign_flag); @@ -921,8 +925,8 @@ function bprint_fmt(buf, fmt) { } _ign_flag = /* false */0; _fmt = fmt$1[3]; - break; - + continue ; + } } }; @@ -2150,8 +2154,8 @@ function fmtty_of_fmt(_fmtty) { ]; case 10 : _fmtty = fmtty[1]; - break; - case 13 : + continue ; + case 13 : return [ /* Format_arg_ty */8, fmtty[2], @@ -2179,8 +2183,8 @@ function fmtty_of_fmt(_fmtty) { case 12 : case 17 : _fmtty = fmtty[2]; - break; - case 18 : + continue ; + case 18 : return CamlinternalFormatBasics.concat_fmtty(fmtty_of_formatting_gen(fmtty[1]), fmtty_of_fmt(fmtty[2])); case 19 : return [ @@ -3656,6 +3660,8 @@ function convert_float(fconv, prec, x) { if (switcher > 23 || switcher < 0) { if (switcher !== 55) { _i = i + 1; + continue ; + } else { return /* true */1; @@ -3666,6 +3672,8 @@ function convert_float(fconv, prec, x) { } else { _i = i + 1; + continue ; + } } }; @@ -3915,24 +3923,24 @@ function make_printf(_k, o, _acc, _fmt) { /* Acc_flush */7, acc ]; - break; - case 11 : + continue ; + case 11 : _fmt = fmt[2]; _acc = [ /* Acc_string_literal */2, acc, fmt[1] ]; - break; - case 12 : + continue ; + case 12 : _fmt = fmt[2]; _acc = [ /* Acc_char_literal */3, acc, fmt[1] ]; - break; - case 13 : + continue ; + case 13 : var rest$3 = fmt[3]; var ty = string_of_fmtty(fmt[2]); return (function(k,acc,rest$3,ty){ @@ -3983,8 +3991,8 @@ function make_printf(_k, o, _acc, _fmt) { acc, fmt[1] ]; - break; - case 18 : + continue ; + case 18 : var match = fmt[1]; if (match[0]) { var rest$7 = fmt[2]; @@ -4003,6 +4011,8 @@ function make_printf(_k, o, _acc, _fmt) { _fmt = match[1][1]; _acc = /* End_of_acc */0; _k = k$prime; + continue ; + } else { var rest$8 = fmt[2]; @@ -4021,6 +4031,8 @@ function make_printf(_k, o, _acc, _fmt) { _fmt = match[1][1]; _acc = /* End_of_acc */0; _k = k$prime$1; + continue ; + } break; case 19 : @@ -4417,10 +4429,14 @@ function output_acc(o, _acc) { if (match[0]) { Pervasives.output_string(o, "@["); _acc = match[1]; + continue ; + } else { Pervasives.output_string(o, "@{"); _acc = match[1]; + continue ; + } break; case 2 : @@ -4475,10 +4491,14 @@ function bufput_acc(b, _acc) { if (match[0]) { Buffer.add_string(b, "@["); _acc = match[1]; + continue ; + } else { Buffer.add_string(b, "@{"); _acc = match[1]; + continue ; + } break; case 2 : @@ -4494,8 +4514,8 @@ function bufput_acc(b, _acc) { return Caml_curry.app1(acc[2], b); case 7 : _acc = acc[1]; - break; - case 8 : + continue ; + case 8 : bufput_acc(b, acc[1]); return Pervasives.invalid_arg(acc[2]); @@ -4533,10 +4553,14 @@ function strput_acc(b, _acc) { if (match[0]) { Buffer.add_string(b, "@["); _acc = match[1]; + continue ; + } else { Buffer.add_string(b, "@{"); _acc = match[1]; + continue ; + } break; case 2 : @@ -4552,8 +4576,8 @@ function strput_acc(b, _acc) { return Buffer.add_string(b, Caml_curry.app1(acc[2], /* () */0)); case 7 : _acc = acc[1]; - break; - case 8 : + continue ; + case 8 : strput_acc(b, acc[1]); return Pervasives.invalid_arg(acc[2]); @@ -4619,10 +4643,14 @@ function open_box_of_string(str) { } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } } }; @@ -4640,6 +4668,8 @@ function open_box_of_string(str) { } else { _j = j + 1; + continue ; + } } }; @@ -4658,6 +4688,8 @@ function open_box_of_string(str) { } else { _j = j + 1; + continue ; + } } else if (match !== 45) { @@ -4665,6 +4697,8 @@ function open_box_of_string(str) { } else { _j = j + 1; + continue ; + } } }; @@ -4947,6 +4981,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (match !== 37) { if (match !== 64) { _str_ind = str_ind + 1; + continue ; + } else { var match$1 = parse_after_at(str_ind + 1, end_ind); @@ -5049,20 +5085,20 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 0 : set_flag(str_ind$1, space); _str_ind = str_ind$1 + 1; - break; - case 3 : + continue ; + case 3 : set_flag(str_ind$1, sharp); _str_ind = str_ind$1 + 1; - break; - case 11 : + continue ; + case 11 : set_flag(str_ind$1, plus); _str_ind = str_ind$1 + 1; - break; - case 13 : + continue ; + case 13 : set_flag(str_ind$1, minus); _str_ind = str_ind$1 + 1; - break; - case 1 : + continue ; + case 1 : case 2 : case 4 : case 5 : @@ -5079,8 +5115,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 16 : set_flag(str_ind$1, zero); _str_ind = str_ind$1 + 1; - break; - + continue ; + } } if (exit === 1) { @@ -6917,6 +6953,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { else { add_in_char_set(char_set, /* "-" */45); _str_ind = str_ind + 1; + continue ; + } }; }; @@ -7011,8 +7049,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { add_in_char_set(char_set, c); _c = c$prime; _str_ind = str_ind + 1; - break; - + continue ; + } }; }; @@ -7045,6 +7083,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { } if (str[str_ind] === " ") { _str_ind = str_ind + 1; + continue ; + } else { return str_ind; @@ -7106,6 +7146,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { else { _acc = new_acc; _str_ind = str_ind + 1; + continue ; + } } }; @@ -7235,6 +7277,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { var match = str.charCodeAt(str_ind); if (match !== 37) { _str_ind = str_ind + 1; + continue ; + } else { if (str_ind + 1 === end_ind) { @@ -7256,8 +7300,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { case 0 : var sub_end = search_subformat_end(str_ind + 2, end_ind, /* "}" */125); _str_ind = sub_end + 2; - break; - case 1 : + continue ; + case 1 : exit = 1; break; case 2 : @@ -7277,15 +7321,21 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (match$2 !== 40) { if (match$2 !== 123) { _str_ind = str_ind + 3; + continue ; + } else { var sub_end$1 = search_subformat_end(str_ind + 3, end_ind, /* "}" */125); _str_ind = sub_end$1 + 2; + continue ; + } } else { var sub_end$2 = search_subformat_end(str_ind + 3, end_ind, /* ")" */41); _str_ind = sub_end$2 + 2; + continue ; + } } } @@ -7300,9 +7350,13 @@ function fmt_ebb_of_string(legacy_behavior, str) { else { var sub_end$3 = search_subformat_end(str_ind + 2, end_ind, /* ")" */41); _str_ind = sub_end$3 + 2; + continue ; + } if (exit === 1) { _str_ind = str_ind + 2; + continue ; + } } @@ -7578,6 +7632,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (exit$1 === 3) { if (legacy_behavior$1) { _sharp = /* false */0; + continue ; + } else { return incompatible_flag(pct_ind, str_ind, symb, "'#'"); @@ -7589,6 +7645,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (space !== 0) { if (legacy_behavior$1) { _space = /* false */0; + continue ; + } else { return incompatible_flag(pct_ind, str_ind, /* " " */32, "'+'"); @@ -7596,6 +7654,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { } else if (legacy_behavior$1) { _plus = /* false */0; + continue ; + } else { return incompatible_flag(pct_ind, str_ind, symb, "'+'"); @@ -7604,6 +7664,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { else if (space !== 0) { if (legacy_behavior$1) { _space = /* false */0; + continue ; + } else { return incompatible_flag(pct_ind, str_ind, symb, "' '"); @@ -7634,6 +7696,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (space !== 0) { if (legacy_behavior$1) { _space = /* false */0; + continue ; + } else { return incompatible_flag(pct_ind, str_ind, /* " " */32, "'+'"); @@ -7676,6 +7740,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (exit === 1) { if (legacy_behavior$1) { _plus = /* false */0; + continue ; + } else { return incompatible_flag(pct_ind, str_ind, symb, "'+'"); @@ -7721,6 +7787,8 @@ function fmt_ebb_of_string(legacy_behavior, str) { if (exit$1 === 1) { if (legacy_behavior$1) { _space = /* false */0; + continue ; + } else { return incompatible_flag(pct_ind, str_ind, symb, "' '"); diff --git a/jscomp/stdlib/camlinternalOO.js b/jscomp/stdlib/camlinternalOO.js index f73b83f4d2..b54993ab65 100644 --- a/jscomp/stdlib/camlinternalOO.js +++ b/jscomp/stdlib/camlinternalOO.js @@ -163,6 +163,8 @@ function find(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -181,6 +183,8 @@ function fold(f, _m, _accu) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -425,6 +429,8 @@ function find$1(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -525,6 +531,8 @@ function get_method_label(table, name) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -897,6 +905,8 @@ function iter_f(obj, _param) { if (param) { Caml_curry.app1(param[1], obj); _param = param[2]; + continue ; + } else { return /* () */0; @@ -972,6 +982,8 @@ function lookup_keys(i, keys, tables) { } else if (tables$1[3] !== /* Empty */0) { _tables = tables$1[3]; + continue ; + } else { var next = [ diff --git a/jscomp/stdlib/filename.js b/jscomp/stdlib/filename.js index b5cbe7d310..384c9a5d96 100644 --- a/jscomp/stdlib/filename.js +++ b/jscomp/stdlib/filename.js @@ -26,6 +26,8 @@ function generic_basename(is_dir_sep, current_dir_name, name) { } else if (Caml_curry.app2(is_dir_sep, name, n)) { _n = n - 1; + continue ; + } else { var _n$1 = n; @@ -40,6 +42,8 @@ function generic_basename(is_dir_sep, current_dir_name, name) { } else { _n$1 = n$1 - 1; + continue ; + } }; } @@ -60,6 +64,8 @@ function generic_dirname(is_dir_sep, current_dir_name, name) { } else if (Caml_curry.app2(is_dir_sep, name, n)) { _n = n - 1; + continue ; + } else { var _n$1 = n; @@ -77,6 +83,8 @@ function generic_dirname(is_dir_sep, current_dir_name, name) { } else if (Caml_curry.app2(is_dir_sep, name, n$2)) { _n$2 = n$2 - 1; + continue ; + } else { return $$String.sub(name, 0, n$2 + 1); @@ -85,6 +93,8 @@ function generic_dirname(is_dir_sep, current_dir_name, name) { } else { _n$1 = n$1 - 1; + continue ; + } }; } @@ -222,6 +232,8 @@ function chop_extension(name) { } else { _i = i - 1; + continue ; + } }; } @@ -306,6 +318,8 @@ function temp_file($staropt$star, prefix, suffix) { } else { _counter = counter + 1; + continue ; + } } else { @@ -352,6 +366,8 @@ function open_temp_file($staropt$star, $staropt$star$1, prefix, suffix) { } else { _counter = counter + 1; + continue ; + } } else { diff --git a/jscomp/stdlib/format.js b/jscomp/stdlib/format.js index 5cc66b31a9..8f6a900f71 100644 --- a/jscomp/stdlib/format.js +++ b/jscomp/stdlib/format.js @@ -268,6 +268,8 @@ function format_pp_token(state, size, param) { } else { _param = param[2]; + continue ; + } } else { @@ -359,7 +361,9 @@ function advance_left(state) { else { take_queue(state$1[27]); format_pp_token(state$1, size < 0 ? pp_infinity : size, match[2]); - return state$1[12] = match[3] + state$1[12]; + state$1[12] = match[3] + state$1[12]; + continue ; + } }; } @@ -865,6 +869,8 @@ function pp_print_list(_$staropt$star, pp_v, ppf, _param) { /* Some */0, pp_sep ]; + continue ; + } else { return Caml_curry.app2(pp_v, ppf, v); @@ -1051,6 +1057,8 @@ function display_blanks(state, _n) { else { Caml_curry.app3(state[17], blank_line, 0, 80); _n = n - 80; + continue ; + } } else { diff --git a/jscomp/stdlib/genlex.js b/jscomp/stdlib/genlex.js index c6427285dc..86abcdfd75 100644 --- a/jscomp/stdlib/genlex.js +++ b/jscomp/stdlib/genlex.js @@ -108,8 +108,8 @@ function make_lexer(keywords) { case 26 : case 32 : Stream.junk(strm__); - break; - case 34 : + continue ; + case 34 : Stream.junk(strm__); reset_buffer(/* () */0); return [ @@ -371,6 +371,8 @@ function make_lexer(keywords) { if (exit$1 === 1) { Stream.junk(strm__$3); store(c$3); + continue ; + } } @@ -491,6 +493,8 @@ function make_lexer(keywords) { if (exit === 1) { Stream.junk(strm__); store(c); + continue ; + } } @@ -529,6 +533,8 @@ function make_lexer(keywords) { if (c >= 48) { Stream.junk(strm__); store(c); + continue ; + } else { exit = 1; @@ -551,6 +557,8 @@ function make_lexer(keywords) { else { Stream.junk(strm__$1); store(c$1); + continue ; + } } else if (switcher > 31 || switcher < 1) { @@ -633,7 +641,9 @@ function make_lexer(keywords) { } else { Stream.junk(strm__); - return store(c); + store(c); + continue ; + } } else { @@ -656,6 +666,8 @@ function make_lexer(keywords) { if (c !== 92) { Stream.junk(strm__); store(c); + continue ; + } else { Stream.junk(strm__); @@ -676,6 +688,8 @@ function make_lexer(keywords) { } } store(c$1); + continue ; + } } else { @@ -812,6 +826,8 @@ function make_lexer(keywords) { var switcher = match[1] - 40; if (switcher > 2 || switcher < 0) { Stream.junk(strm__); + continue ; + } else { switch (switcher) { @@ -835,8 +851,8 @@ function make_lexer(keywords) { } case 1 : Stream.junk(strm__); - break; - case 2 : + continue ; + case 2 : Stream.junk(strm__); var strm__$2 = strm__; while(true) { @@ -849,7 +865,9 @@ function make_lexer(keywords) { return comment(strm__$2); } else { - return Stream.junk(strm__$2); + Stream.junk(strm__$2); + continue ; + } } else { diff --git a/jscomp/stdlib/hashtbl.js b/jscomp/stdlib/hashtbl.js index 18cd890e6e..7eb442d4ef 100644 --- a/jscomp/stdlib/hashtbl.js +++ b/jscomp/stdlib/hashtbl.js @@ -80,6 +80,8 @@ function power_2_above(_x, n) { } else { _x = x * 2; + continue ; + } }; } @@ -247,6 +249,8 @@ function find(h, key) { if (param) { if (Caml_primitive.caml_compare(key$1, param[1])) { _param = param[3]; + continue ; + } else { return param[2]; @@ -290,6 +294,8 @@ function find_all(h, key) { var rest = param[3]; if (Caml_primitive.caml_compare(param[1], key)) { _param = rest; + continue ; + } else { return [ @@ -368,6 +374,8 @@ function mem(h, key) { if (param) { if (Caml_primitive.caml_compare(param[1], key)) { _param = param[3]; + continue ; + } else { return /* true */1; @@ -386,6 +394,8 @@ function iter(f, h) { if (param) { Caml_curry.app2(f, param[1], param[2]); _param = param[3]; + continue ; + } else { return /* () */0; @@ -407,6 +417,8 @@ function fold(f, h, init) { if (b) { _accu = Caml_curry.app3(f, b[1], b[2], accu); _b = b[3]; + continue ; + } else { return accu; @@ -428,6 +440,8 @@ function bucket_length(_accu, _param) { if (param) { _param = param[3]; _accu = accu + 1; + continue ; + } else { return accu; @@ -529,6 +543,8 @@ function MakeSeeded(H) { } else { _param = param[3]; + continue ; + } } else { @@ -564,6 +580,8 @@ function MakeSeeded(H) { } else { _param = rest; + continue ; + } } else { @@ -636,6 +654,8 @@ function MakeSeeded(H) { } else { _param = param[3]; + continue ; + } } else { @@ -738,6 +758,8 @@ function Make(H) { } else { _param = param[3]; + continue ; + } } else { @@ -773,6 +795,8 @@ function Make(H) { } else { _param = rest; + continue ; + } } else { @@ -845,6 +869,8 @@ function Make(H) { } else { _param = param[3]; + continue ; + } } else { diff --git a/jscomp/stdlib/list.js b/jscomp/stdlib/list.js index ef8ddda12e..5e0269d71b 100644 --- a/jscomp/stdlib/list.js +++ b/jscomp/stdlib/list.js @@ -15,6 +15,8 @@ function length(l) { if (param) { _param = param[2]; _len = len + 1; + continue ; + } else { return len; @@ -54,6 +56,8 @@ function nth(l, n) { if (n$1) { _n = n$1 - 1; _l = l$1[2]; + continue ; + } else { return l$1[1]; @@ -77,6 +81,8 @@ function rev_append(_l1, _l2) { l2 ]; _l1 = l1[2]; + continue ; + } else { return l2; @@ -142,6 +148,8 @@ function rev_map(f, l) { Caml_curry.app1(f, param[1]), accu ]; + continue ; + } else { return accu; @@ -155,6 +163,8 @@ function iter(f, _param) { if (param) { Caml_curry.app1(f, param[1]); _param = param[2]; + continue ; + } else { return /* () */0; @@ -173,6 +183,8 @@ function iteri(f, l) { Caml_curry.app2(f$1, i, param[1]); _param = param[2]; _i = i + 1; + continue ; + } else { return /* () */0; @@ -187,6 +199,8 @@ function fold_left(f, _accu, _l) { if (l) { _l = l[2]; _accu = Caml_curry.app2(f, accu, l[1]); + continue ; + } else { return accu; @@ -242,6 +256,8 @@ function rev_map2(f, l1, l2) { Caml_curry.app2(f, l1$1[1], l2$1[1]), accu ]; + continue ; + } else { return Pervasives.invalid_arg("List.rev_map2"); @@ -265,6 +281,8 @@ function iter2(f, _l1, _l2) { Caml_curry.app2(f, l1[1], l2[1]); _l2 = l2[2]; _l1 = l1[2]; + continue ; + } else { return Pervasives.invalid_arg("List.iter2"); @@ -289,6 +307,8 @@ function fold_left2(f, _accu, _l1, _l2) { _l2 = l2[2]; _l1 = l1[2]; _accu = Caml_curry.app3(f, accu, l1[1], l2[1]); + continue ; + } else { return Pervasives.invalid_arg("List.fold_left2"); @@ -326,6 +346,8 @@ function for_all(p, _param) { if (param) { if (Caml_curry.app1(p, param[1])) { _param = param[2]; + continue ; + } else { return /* false */0; @@ -346,6 +368,8 @@ function exists(p, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -363,6 +387,8 @@ function for_all2(p, _l1, _l2) { if (Caml_curry.app2(p, l1[1], l2[1])) { _l2 = l2[2]; _l1 = l1[2]; + continue ; + } else { return /* false */0; @@ -393,6 +419,8 @@ function exists2(p, _l1, _l2) { else { _l2 = l2[2]; _l1 = l1[2]; + continue ; + } } else { @@ -414,6 +442,8 @@ function mem(x, _param) { if (param) { if (Caml_primitive.caml_compare(param[1], x)) { _param = param[2]; + continue ; + } else { return /* true */1; @@ -434,6 +464,8 @@ function memq(x, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -449,6 +481,8 @@ function assoc(x, _param) { var match = param[1]; if (Caml_primitive.caml_compare(match[1], x)) { _param = param[2]; + continue ; + } else { return match[2]; @@ -470,6 +504,8 @@ function assq(x, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -484,6 +520,8 @@ function mem_assoc(x, _param) { if (param) { if (Caml_primitive.caml_compare(param[1][1], x)) { _param = param[2]; + continue ; + } else { return /* true */1; @@ -504,6 +542,8 @@ function mem_assq(x, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -562,6 +602,8 @@ function find(p, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -587,9 +629,13 @@ function find_all(p) { x, accu ]; + continue ; + } else { _param = l; + continue ; + } } else { @@ -617,6 +663,8 @@ function partition(p, l) { x, yes ]; + continue ; + } else { _param = l$1; @@ -625,6 +673,8 @@ function partition(p, l) { x, no ]; + continue ; + } } else { @@ -726,6 +776,8 @@ function chop(_k, _l) { if (l) { _l = l[2]; _k = k - 1; + continue ; + } else { throw [ @@ -925,6 +977,8 @@ function stable_sort(cmp, l) { accu ]; _l1 = l1[2]; + continue ; + } else { _accu = [ @@ -933,6 +987,8 @@ function stable_sort(cmp, l) { accu ]; _l2 = l2$1[2]; + continue ; + } } else { @@ -1124,6 +1180,8 @@ function stable_sort(cmp, l) { accu ]; _l1 = l1[2]; + continue ; + } else { _accu = [ @@ -1132,6 +1190,8 @@ function stable_sort(cmp, l) { accu ]; _l2 = l2$1[2]; + continue ; + } } else { @@ -1446,6 +1506,8 @@ function sort_uniq(cmp, l) { accu ]; _l1 = t1; + continue ; + } else { _accu = [ @@ -1454,6 +1516,8 @@ function sort_uniq(cmp, l) { accu ]; _l2 = t2; + continue ; + } } else { @@ -1464,6 +1528,8 @@ function sort_uniq(cmp, l) { ]; _l2 = t2; _l1 = t1; + continue ; + } } else { @@ -1768,6 +1834,8 @@ function sort_uniq(cmp, l) { accu ]; _l1 = t1; + continue ; + } else { _accu = [ @@ -1776,6 +1844,8 @@ function sort_uniq(cmp, l) { accu ]; _l2 = t2; + continue ; + } } else { @@ -1786,6 +1856,8 @@ function sort_uniq(cmp, l) { ]; _l2 = t2; _l1 = t1; + continue ; + } } else { diff --git a/jscomp/stdlib/map.js b/jscomp/stdlib/map.js index ef379dee71..8674f2ef48 100644 --- a/jscomp/stdlib/map.js +++ b/jscomp/stdlib/map.js @@ -142,6 +142,8 @@ function Make(funarg) { var c = Caml_curry.app2(funarg[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -159,6 +161,8 @@ function Make(funarg) { var c = Caml_curry.app2(funarg[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return /* true */1; @@ -176,6 +180,8 @@ function Make(funarg) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return [ @@ -197,6 +203,8 @@ function Make(funarg) { var r = param[4]; if (r) { _param = r; + continue ; + } else { return [ @@ -268,6 +276,8 @@ function Make(funarg) { iter(f, param[1]); Caml_curry.app2(f, param[2], param[3]); _param = param[4]; + continue ; + } else { return /* () */0; @@ -318,6 +328,8 @@ function Make(funarg) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -331,6 +343,8 @@ function Make(funarg) { if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; + continue ; + } else { return /* false */0; @@ -357,6 +371,8 @@ function Make(funarg) { } else { _param = param[4]; + continue ; + } } else { @@ -583,6 +599,8 @@ function Make(funarg) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -609,6 +627,8 @@ function Make(funarg) { else { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } } } @@ -638,6 +658,8 @@ function Make(funarg) { else if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } else { return /* false */0; @@ -678,6 +700,8 @@ function Make(funarg) { ], bindings_aux(accu, param[4]) ]; + continue ; + } else { return accu; diff --git a/jscomp/stdlib/parsing.js b/jscomp/stdlib/parsing.js index 9b332f662d..f81628b4ad 100644 --- a/jscomp/stdlib/parsing.js +++ b/jscomp/stdlib/parsing.js @@ -99,20 +99,20 @@ function yyparse(tables, start, lexer, lexbuf) { env[10] = lexbuf[12]; _arg = t; _cmd = /* Token_read */1; - break; - case 1 : + continue ; + case 1 : throw Parse_error; case 2 : grow_stacks(/* () */0); _arg = /* () */0; _cmd = /* Stacks_grown_1 */2; - break; - case 3 : + continue ; + case 3 : grow_stacks(/* () */0); _arg = /* () */0; _cmd = /* Stacks_grown_2 */3; - break; - case 4 : + continue ; + case 4 : var match$1; try { match$1 = [ @@ -135,13 +135,13 @@ function yyparse(tables, start, lexer, lexbuf) { } _arg = match$1[2]; _cmd = match$1[1]; - break; - case 5 : + continue ; + case 5 : Caml_curry.app1(tables[14], "syntax error"); _arg = /* () */0; _cmd = /* Error_detected */5; - break; - + continue ; + } }; } @@ -190,6 +190,8 @@ function symbol_start_pos() { } else { _i = i - 1; + continue ; + } } }; diff --git a/jscomp/stdlib/pervasives.js b/jscomp/stdlib/pervasives.js index 37bc6fadef..59d132e26d 100644 --- a/jscomp/stdlib/pervasives.js +++ b/jscomp/stdlib/pervasives.js @@ -139,6 +139,8 @@ function valid_float_lexem(s) { } else { _i = i + 1; + continue ; + } } else if (match !== 45) { @@ -146,6 +148,8 @@ function valid_float_lexem(s) { } else { _i = i + 1; + continue ; + } } }; @@ -230,6 +234,8 @@ function flush_all() { } _param = param[2]; + continue ; + } else { return /* () */0; @@ -348,6 +354,8 @@ function unsafe_really_input(ic, s, _ofs, _len) { if (r) { _len = len - r; _ofs = ofs + r; + continue ; + } else { throw Caml_exceptions.End_of_file; @@ -386,6 +394,8 @@ function input_line(chan) { Caml_string.caml_blit_bytes(hd, 0, buf, pos - len, len); _param = param[2]; _pos = pos - len; + continue ; + } else { return buf; @@ -423,6 +433,8 @@ function input_line(chan) { beg, accu ]; + continue ; + } } else if (accu) { diff --git a/jscomp/stdlib/printexc.js b/jscomp/stdlib/printexc.js index 78a81605fd..30fecac66a 100644 --- a/jscomp/stdlib/printexc.js +++ b/jscomp/stdlib/printexc.js @@ -199,6 +199,8 @@ function to_string(x) { } else { _param = param[2]; + continue ; + } } else if (x === Caml_exceptions.Out_of_memory) { @@ -519,6 +521,8 @@ function backtrace_slots(raw_backtrace) { } else { _i = i - 1; + continue ; + } } else { diff --git a/jscomp/stdlib/queue.js b/jscomp/stdlib/queue.js index db3bc050ff..b6abaa429b 100644 --- a/jscomp/stdlib/queue.js +++ b/jscomp/stdlib/queue.js @@ -99,6 +99,8 @@ function copy(q) { prev[2] = res; _cell = cell[2]; _prev = res; + continue ; + } else { return 0; @@ -138,6 +140,8 @@ function iter(f, q) { Caml_curry.app1(f, cell[1]); if (cell !== tail) { _cell = cell[2]; + continue ; + } else { return 0; @@ -164,6 +168,8 @@ function fold(f, accu, q) { else { _cell = cell[2]; _accu = accu$2; + continue ; + } }; } diff --git a/jscomp/stdlib/random.js b/jscomp/stdlib/random.js index 1a08b53c04..e41df0b40d 100644 --- a/jscomp/stdlib/random.js +++ b/jscomp/stdlib/random.js @@ -83,10 +83,13 @@ function $$int(s, bound) { while(true) { var r = bits(s$1); var v = r % n; - if (r - v <= 1073741823 - n + 1) { + if (r - v > 1073741823 - n + 1) { + continue ; + + } + else { return v; } - }; } } @@ -103,10 +106,13 @@ function int32(s, bound) { var b2 = ((bits(s$1) & 1) << 30); var r = b1 | b2; var v = r % n; - if (r - v <= Int32.max_int - n + 1) { + if (r - v > Int32.max_int - n + 1) { + continue ; + + } + else { return v; } - }; } } @@ -124,10 +130,13 @@ function int64(s, bound) { var b3 = ((bits(s$1) & 7) << 60); var r = b1 | b2 | b3; var v = r % n; - if (r - v <= Int64.max_int - n + 1) { + if (r - v > Int64.max_int - n + 1) { + continue ; + + } + else { return v; } - }; } } diff --git a/jscomp/stdlib/scanf.js b/jscomp/stdlib/scanf.js index 9569f5d7c5..cc81a32003 100644 --- a/jscomp/stdlib/scanf.js +++ b/jscomp/stdlib/scanf.js @@ -376,14 +376,18 @@ function check_char(ib, _c) { return /* () */0; } else { - return ib$1[3] = /* false */0; + ib$1[3] = /* false */0; + continue ; + } } else if (switcher === 3 || switcher === 2) { return /* () */0; } else { - return ib$1[3] = /* false */0; + ib$1[3] = /* false */0; + continue ; + } } }; @@ -405,6 +409,8 @@ function check_char(ib, _c) { else if (c === /* "\n" */10) { ib[3] = /* false */0; _c = /* "\n" */10; + continue ; + } else { var s$1 = character_mismatch_err(c, ci); @@ -546,11 +552,15 @@ function scan_decimal_digits(_width, ib) { else { var width$1 = ignore_char(width, ib); _width = width$1; + continue ; + } } else if (c >= 48) { var width$2 = store_char(width, ib, c); _width = width$2; + continue ; + } else { return width; @@ -612,12 +622,16 @@ function scan_digits_plus(basis, digitp, width, ib) { } else if (Caml_curry.app1(digitp, c$1)) { _width = store_char(width$1, ib, c$1); + continue ; + } else if (c$1 !== 95) { return width$1; } else { _width = ignore_char(width$1, ib); + continue ; + } } else { @@ -982,6 +996,8 @@ function scan_string(stp, width, ib) { } else { _width = store_char(width$1, ib, c); + continue ; + } } else { @@ -989,6 +1005,8 @@ function scan_string(stp, width, ib) { if (switcher > 4 || switcher < 0) { if (switcher !== 23) { _width = store_char(width$1, ib, c); + continue ; + } else { return width$1; @@ -996,6 +1014,8 @@ function scan_string(stp, width, ib) { } else if (switcher === 3 || switcher === 2) { _width = store_char(width$1, ib, c); + continue ; + } else { return width$1; @@ -1300,6 +1320,8 @@ function scan_caml_string(width, ib) { if (c !== 34) { if (c !== 92) { _width = store_char(width, ib, c); + continue ; + } else { var width$1 = ignore_char(width, ib); @@ -1331,6 +1353,8 @@ function scan_caml_string(width, ib) { } else { _width = ignore_char(width, ib); + continue ; + } }; }; @@ -1394,6 +1418,8 @@ function scan_chars_in_char_set(char_set, scan_indic, width, ib) { if (i > 0 && !ib[1] && CamlinternalFormat.is_in_char_set(char_set, c) && c !== stp) { store_char(Pervasives.max_int, ib, c); _i = i - 1; + continue ; + } else { return 0; @@ -1530,12 +1556,21 @@ function take_format_readers(k, _fmt) { case 7 : case 8 : _fmt = fmt[4]; - break; - case 14 : + continue ; + case 14 : return take_fmtty_format_readers(k, CamlinternalFormatBasics.erase_rel(CamlinternalFormat.symm(fmt[2])), fmt[3]); case 18 : var match = fmt[1]; - _fmt = match[0] ? CamlinternalFormatBasics.concat_fmt(match[1][1], fmt[2]) : CamlinternalFormatBasics.concat_fmt(match[1][1], fmt[2]); + if (match[0]) { + _fmt = CamlinternalFormatBasics.concat_fmt(match[1][1], fmt[2]); + continue ; + + } + else { + _fmt = CamlinternalFormatBasics.concat_fmt(match[1][1], fmt[2]); + continue ; + + } break; case 19 : var fmt_rest = fmt[1]; @@ -1558,8 +1593,8 @@ function take_format_readers(k, _fmt) { case 17 : case 21 : _fmt = fmt[2]; - break; - case 0 : + continue ; + case 0 : case 1 : case 9 : case 10 : @@ -1567,8 +1602,8 @@ function take_format_readers(k, _fmt) { case 16 : case 22 : _fmt = fmt[1]; - break; - case 23 : + continue ; + case 23 : var k$1 = k; var ign = fmt[1]; var fmt$1 = fmt[2]; @@ -1617,8 +1652,8 @@ function take_format_readers(k, _fmt) { case 20 : case 24 : _fmt = fmt[3]; - break; - + continue ; + } } }; @@ -1634,12 +1669,12 @@ function take_fmtty_format_readers(k, _fmtty, fmt) { switch (fmtty[0]) { case 8 : _fmtty = fmtty[2]; - break; - case 9 : + continue ; + case 9 : var ty = CamlinternalFormat.trans(CamlinternalFormat.symm(fmtty[1]), fmtty[2]); _fmtty = CamlinternalFormatBasics.concat_fmtty(ty, fmtty[3]); - break; - case 0 : + continue ; + case 0 : case 1 : case 2 : case 3 : @@ -1651,8 +1686,8 @@ function take_fmtty_format_readers(k, _fmtty, fmt) { case 11 : case 12 : _fmtty = fmtty[1]; - break; - case 13 : + continue ; + case 13 : var fmt_rest = fmtty[1]; return (function(fmt_rest){ return function (reader) { @@ -1841,6 +1876,8 @@ function make_scanf(ib, _fmt, readers) { case 10 : if (end_of_input(ib)) { _fmt = fmt[1]; + continue ; + } else { throw [ @@ -1855,12 +1892,12 @@ function make_scanf(ib, _fmt, readers) { return check_char(ib, param); }, fmt[1]); _fmt = fmt[2]; - break; - case 12 : + continue ; + case 12 : check_char(ib, fmt[1]); _fmt = fmt[2]; - break; - case 13 : + continue ; + case 13 : scan_caml_string(width_of_pad_opt(fmt[1]), ib); var s = token(ib); var fmt$1; @@ -1928,17 +1965,21 @@ function make_scanf(ib, _fmt, readers) { return check_char(ib, param); }, CamlinternalFormat.string_of_formatting_lit(fmt[1])); _fmt = fmt[2]; - break; - case 18 : + continue ; + case 18 : var match$5 = fmt[1]; check_char(ib, /* "@" */64); if (match$5[0]) { check_char(ib, /* "[" */91); _fmt = CamlinternalFormatBasics.concat_fmt(match$5[1][1], fmt[2]); + continue ; + } else { check_char(ib, /* "{" */123); _fmt = CamlinternalFormatBasics.concat_fmt(match$5[1][1], fmt[2]); + continue ; + } break; case 19 : @@ -2142,6 +2183,8 @@ function kscanf(ib, ef, param) { if (args) { _args = args[2]; _f = Caml_curry.app1(f$1, args[1]); + continue ; + } else { return f$1; diff --git a/jscomp/stdlib/set.js b/jscomp/stdlib/set.js index afc58fe0f6..72732a3699 100644 --- a/jscomp/stdlib/set.js +++ b/jscomp/stdlib/set.js @@ -160,6 +160,8 @@ function Make(funarg) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return param[2]; @@ -177,6 +179,8 @@ function Make(funarg) { var r = param[3]; if (r) { _param = r; + continue ; + } else { return param[2]; @@ -274,6 +278,8 @@ function Make(funarg) { var c = Caml_curry.app2(funarg[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[3]; + continue ; + } else { return /* true */1; @@ -408,6 +414,8 @@ function Make(funarg) { e ]; _s = s[1]; + continue ; + } else { return e; @@ -429,6 +437,8 @@ function Make(funarg) { else { _e2 = cons_enum(e2[2], e2[3]); _e1 = cons_enum(e1[2], e1[3]); + continue ; + } } else { @@ -468,6 +478,8 @@ function Make(funarg) { 0 ], l2)) { _s1 = r1; + continue ; + } else { return /* false */0; @@ -481,6 +493,8 @@ function Make(funarg) { 0 ], r2)) { _s1 = l1; + continue ; + } else { return /* false */0; @@ -489,6 +503,8 @@ function Make(funarg) { else if (subset(l1, l2)) { _s2 = r2; _s1 = r1; + continue ; + } else { return /* false */0; @@ -510,6 +526,8 @@ function Make(funarg) { iter(f, param[1]); Caml_curry.app1(f, param[2]); _param = param[3]; + continue ; + } else { return /* () */0; @@ -523,6 +541,8 @@ function Make(funarg) { if (s) { _accu = Caml_curry.app2(f, s[2], fold(f, s[1], accu)); _s = s[3]; + continue ; + } else { return accu; @@ -536,6 +556,8 @@ function Make(funarg) { if (Caml_curry.app1(p, param[2])) { if (for_all(p, param[1])) { _param = param[3]; + continue ; + } else { return /* false */0; @@ -562,6 +584,8 @@ function Make(funarg) { } else { _param = param[3]; + continue ; + } } else { @@ -638,6 +662,8 @@ function Make(funarg) { param[2], elements_aux(accu, param[3]) ]; + continue ; + } else { return accu; @@ -655,6 +681,8 @@ function Make(funarg) { var c = Caml_curry.app2(funarg[1], x, v); if (c) { _param = c < 0 ? param[1] : param[3]; + continue ; + } else { return v; diff --git a/jscomp/stdlib/sort.js b/jscomp/stdlib/sort.js index c0a9b0269c..5c201693fe 100644 --- a/jscomp/stdlib/sort.js +++ b/jscomp/stdlib/sort.js @@ -102,6 +102,8 @@ function list(order, l) { if (llist) { if (llist[2]) { _llist = merge2(llist); + continue ; + } else { return llist[1]; @@ -163,10 +165,14 @@ function array(cmp, arr) { if (j - lo <= hi - i) { qsort(lo, j); _lo = i; + continue ; + } else { qsort(i, hi); _hi = j; + continue ; + } } else { diff --git a/jscomp/stdlib/stream.js b/jscomp/stdlib/stream.js index 99e8a92eda..900eb7f803 100644 --- a/jscomp/stdlib/stream.js +++ b/jscomp/stdlib/stream.js @@ -54,6 +54,8 @@ function get_data(count, _d) { } else { _d = d2; + continue ; + } } else if (match[0]) { @@ -86,8 +88,8 @@ function get_data(count, _d) { _d = tag === 250 ? f[1] : ( tag === 246 ? CamlinternalLazy.force_lazy_block(f) : f ); - break; - case 3 : + continue ; + case 3 : var g = d[1]; var match$1 = g[1]; if (match$1) { @@ -205,8 +207,8 @@ function peek(s) { tag === 246 ? CamlinternalLazy.force_lazy_block(f) : f ); s[1] = d$1; - break; - case 3 : + continue ; + case 3 : var g = match[1]; var match$1 = g[1]; if (match$1) { @@ -278,10 +280,13 @@ function junk(s) { } if (exit === 1) { var match$2 = peek(s); - if (!match$2) { + if (match$2) { + continue ; + + } + else { return /* () */0; } - } }; @@ -364,6 +369,8 @@ function iter(f, strm) { junk(strm); Caml_curry.app1(f, match[1]); _param = /* () */0; + continue ; + } else { return /* () */0; diff --git a/jscomp/stdlib/string.js b/jscomp/stdlib/string.js index 9d3816643e..7f938d23bd 100644 --- a/jscomp/stdlib/string.js +++ b/jscomp/stdlib/string.js @@ -145,6 +145,8 @@ function escaped(s) { if (exit === 1) { if (Caml_string.caml_is_printable(c)) { _i = i + 1; + continue ; + } else { return /* true */1; diff --git a/jscomp/stdlib/weak.js b/jscomp/stdlib/weak.js index eb57e5931b..0bf5ee4350 100644 --- a/jscomp/stdlib/weak.js +++ b/jscomp/stdlib/weak.js @@ -74,9 +74,13 @@ function Make(H) { if (match) { _accu = Caml_curry.app2(f, match[1], accu); _i = i + 1; + continue ; + } else { _i = i + 1; + continue ; + } } }; @@ -96,9 +100,13 @@ function Make(H) { if (match) { Caml_curry.app1(f, match[1]); _i = i + 1; + continue ; + } else { _i = i + 1; + continue ; + } } }; @@ -119,9 +127,13 @@ function Make(H) { if (match !== 0) { Caml_curry.app3(f, b, t[2][j], i); _i = i + 1; + continue ; + } else { _i = i + 1; + continue ; + } } }; @@ -139,6 +151,8 @@ function Make(H) { Caml_primitive.caml_weak_check(b, i) ? 1 : 0 ); _i = i + 1; + continue ; + } }; }; @@ -167,15 +181,21 @@ function Make(H) { if (j >= prev_len) { if (Caml_primitive.caml_weak_check(bucket, i)) { _i = i + 1; + continue ; + } else if (Caml_primitive.caml_weak_check(bucket, j)) { Caml_primitive.caml_weak_blit(bucket, j, bucket, i, 1); hbucket[i] = hbucket[j]; _j = j - 1; _i = i + 1; + continue ; + } else { _j = j - 1; + continue ; + } } else { @@ -261,6 +281,8 @@ function Make(H) { } else if (Caml_primitive.caml_weak_check(bucket, i)) { _i = i + 1; + continue ; + } else { Caml_curry.app3(setter, bucket, i, d); @@ -300,18 +322,26 @@ function Make(H) { } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } }; }; @@ -351,14 +381,20 @@ function Make(H) { } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } }; }; @@ -398,21 +434,31 @@ function Make(H) { accu ]; _i = i + 1; + continue ; + } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } } else { _i = i + 1; + continue ; + } }; }; diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 520a3f4bd6..a543c5e8e2 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -88,6 +88,8 @@ for_loop_test.cmo : mt.cmo ../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.cmx : mt.cmx +format_regression.cmo : +format_regression.cmx : global_exception_regression_test.cmo : mt.cmo global_exception_regression_test.cmx : mt.cmx google_closure_test.cmo : test_google_closure.cmo mt.cmo @@ -116,6 +118,8 @@ list_test.cmo : ../stdlib/pervasives.cmi mt.cmo ../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 +loop_regression_test.cmx : mt.cmx loop_suites_test.cmo : mt.cmo 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 \ @@ -448,6 +452,8 @@ for_loop_test.cmo : mt.cmo ../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.cmj : mt.cmj +format_regression.cmo : +format_regression.cmj : global_exception_regression_test.cmo : mt.cmo global_exception_regression_test.cmj : mt.cmj google_closure_test.cmo : test_google_closure.cmo mt.cmo @@ -476,6 +482,8 @@ list_test.cmo : ../stdlib/pervasives.cmi mt.cmo ../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 +loop_regression_test.cmj : mt.cmj loop_suites_test.cmo : mt.cmo 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 \ diff --git a/jscomp/test/a_scope_bug.js b/jscomp/test/a_scope_bug.js index 5049c92deb..6b065057e2 100644 --- a/jscomp/test/a_scope_bug.js +++ b/jscomp/test/a_scope_bug.js @@ -9,6 +9,8 @@ function odd(_z) { var a = even + 4 + even; console.log("" + a); _z = 32; + continue ; + }; } diff --git a/jscomp/test/arith_lexer.js b/jscomp/test/arith_lexer.js index 175f9b1fa9..2ef59b31c8 100644 --- a/jscomp/test/arith_lexer.js +++ b/jscomp/test/arith_lexer.js @@ -32,13 +32,15 @@ function __ocaml_lex_lexeme_rec(lexbuf, ___ocaml_lex_state) { if (__ocaml_lex_state$1 > 9 || __ocaml_lex_state$1 < 0) { Caml_curry.app1(lexbuf[1], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } else { switch (__ocaml_lex_state$1) { case 0 : ___ocaml_lex_state = 0; - break; - case 1 : + continue ; + case 1 : return [ /* NUMERAL */0, Caml_format.caml_int_of_string(Lexing.lexeme(lexbuf)) diff --git a/jscomp/test/array_test.js b/jscomp/test/array_test.js index 58e0b1490a..711df52aac 100644 --- a/jscomp/test/array_test.js +++ b/jscomp/test/array_test.js @@ -18,6 +18,8 @@ function is_sorted(x) { } else if (Caml_primitive.caml_lessthan(x[i], x[i + 1])) { _i = i + 1; + continue ; + } else { return /* false */0; diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index 86a52e1c64..e2d1be8c97 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -15,8 +15,15 @@ function $$eval(_bdd, vars) { return /* true */1; } } + else if (vars[bdd[2]]) { + _bdd = bdd[4]; + continue ; + + } else { - _bdd = vars[bdd[2]] ? bdd[4] : bdd[1]; + _bdd = bdd[1]; + continue ; + } }; } @@ -90,6 +97,8 @@ function resize(newSize) { newArr[ind] ]; _bucket = bucket[2]; + continue ; + } } else { @@ -165,6 +174,8 @@ function mkNode(low, v, high) { } else { _b = b[2]; + continue ; + } } else { diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 117e6d4e67..e1f35b269b 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -23,6 +23,8 @@ function test() { } }(n,acc)); _n = n - 1; + continue ; + } else { return Caml_curry.app1(acc, /* () */0); diff --git a/jscomp/test/demo.js b/jscomp/test/demo.js index 307eb76eb5..ccad794b2e 100644 --- a/jscomp/test/demo.js +++ b/jscomp/test/demo.js @@ -110,9 +110,9 @@ function ui_layout(compile, lookup, appContext) { "bid": bid, "ask": ask }); - var text = Caml_curry.app1(bid.toFixed, 2); - var text$1 = Caml_curry.app1(ask.toFixed, 2); - var text$2 = Caml_curry.app1(result.toFixed, 2); + var text = bid.toFixed(2); + var text$1 = ask.toFixed(2); + var text$2 = result.toFixed(2); return /* array */[ { "label": { diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index 5f65fe7157..13c88f08f3 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -49,7 +49,7 @@ ReactDom.render(React.createClass({ "alt": "pic" }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!")); } - }), Caml_curry.app1(document.getElementById, "hi")); + }), document.getElementById("hi")); exports.fib = fib; exports.sum = sum; diff --git a/jscomp/test/ext_filename.js b/jscomp/test/ext_filename.js index 88e1c15e08..5e3e4b5473 100644 --- a/jscomp/test/ext_filename.js +++ b/jscomp/test/ext_filename.js @@ -28,6 +28,8 @@ function absolute_path(s) { } else if (base === Filename.current_dir_name) { _s = dir; + continue ; + } else if (base === Filename.parent_dir_name) { return Caml_curry.app1(Filename.dirname, aux(dir)); @@ -77,6 +79,8 @@ function relative_path(file1, file2) { if (dir1[1] === dir2[1]) { _dir2 = dir2[2]; _dir1 = dir1[2]; + continue ; + } else { exit = 1; diff --git a/jscomp/test/ext_list.js b/jscomp/test/ext_list.js index 5d8a62c005..ce8880192b 100644 --- a/jscomp/test/ext_list.js +++ b/jscomp/test/ext_list.js @@ -21,6 +21,8 @@ function filter_map(f, _xs) { } else { _xs = ys; + continue ; + } } else { @@ -37,6 +39,8 @@ function same_length(_xs, _ys) { if (ys) { _ys = ys[2]; _xs = xs[2]; + continue ; + } else { return /* false */0; @@ -69,6 +73,8 @@ function filter_mapi(f, xs) { else { _xs = ys; _i = i + 1; + continue ; + } } else { @@ -98,6 +104,8 @@ function filter_map2(f, _xs, _ys) { else { _ys = vs; _xs = us; + continue ; + } } else { @@ -135,6 +143,8 @@ function filter_map2i(f, xs, ys) { _ys = vs; _xs = us; _i = i + 1; + continue ; + } } else { @@ -163,6 +173,8 @@ function rev_map_append(f, _l1, _l2) { l2 ]; _l1 = l1[2]; + continue ; + } else { return l2; @@ -183,6 +195,8 @@ function flat_map2(f, lx, ly) { _ly = ly$1[2]; _lx = lx$1[2]; _acc = List.rev_append(Caml_curry.app2(f, lx$1[1], ly$1[1]), acc); + continue ; + } else { return Pervasives.invalid_arg("Ext_list.flat_map2"); @@ -206,6 +220,8 @@ function flat_map(f, lx) { if (lx$1) { _lx = lx$1[2]; _acc = List.rev_append(Caml_curry.app1(f, lx$1[1]), acc); + continue ; + } else { return List.rev(acc); @@ -322,6 +338,8 @@ function exclude_tail(x) { x$1[1], acc ]; + continue ; + } else { return List.rev(acc); @@ -393,6 +411,8 @@ function drop(_n, _h) { if (h) { _h = List.tl(h); _n = n - 1; + continue ; + } else { return Pervasives.invalid_arg("Ext_list.drop"); @@ -411,6 +431,8 @@ function for_all_ret(p, _param) { var a = param[1]; if (Caml_curry.app1(p, a)) { _param = param[2]; + continue ; + } else { return [ @@ -435,6 +457,8 @@ function for_all_opt(p, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -462,6 +486,8 @@ function rev_map_acc(acc, f, l) { Caml_curry.app1(f, param[1]), accu ]; + continue ; + } else { return accu; diff --git a/jscomp/test/ext_string.js b/jscomp/test/ext_string.js index 244c8f5a77..7c6ea06129 100644 --- a/jscomp/test/ext_string.js +++ b/jscomp/test/ext_string.js @@ -35,14 +35,20 @@ function split_by($staropt$star, is_delim, str) { v, acc ]; + continue ; + } else { _pos = pos - 1; _last_pos = pos; + continue ; + } } else { _pos = pos - 1; + continue ; + } }; } @@ -86,6 +92,8 @@ function ends_with(s, beg) { else if (s[j] === beg[k]) { _k = k - 1; _j = j - 1; + continue ; + } else { return /* false */0; @@ -111,6 +119,8 @@ function escaped(s) { } else { _i = i + 1; + continue ; + } } else if (switcher > 57 || switcher < 1) { @@ -118,6 +128,8 @@ function escaped(s) { } else { _i = i + 1; + continue ; + } } else if (match >= 11) { @@ -149,6 +161,8 @@ function for_all(p, s) { } else if (Caml_curry.app1(p, s.charCodeAt(i))) { _i = i + 1; + continue ; + } else { return /* false */0; diff --git a/jscomp/test/fib.js b/jscomp/test/fib.js index 4f5e5b73b4..901cfb9c30 100644 --- a/jscomp/test/fib.js +++ b/jscomp/test/fib.js @@ -26,6 +26,8 @@ function fib2(n) { _i = i + 1; _b = a + b; _a = b; + continue ; + } }; } diff --git a/jscomp/test/format_regression.d.ts b/jscomp/test/format_regression.d.ts new file mode 100644 index 0000000000..75b134c922 --- /dev/null +++ b/jscomp/test/format_regression.d.ts @@ -0,0 +1,7 @@ +export var peek_queue: (param : any) => any ; +export var int_of_size: (param : any) => any ; +export var take_queue: (param : any) => any ; +export var format_pp_token: (param : any, param : any) => any ; +export var pp_infinity: any ; +export var advance_loop: (state : any) => any ; + diff --git a/jscomp/test/format_regression.js b/jscomp/test/format_regression.js new file mode 100644 index 0000000000..5e64e4b50e --- /dev/null +++ b/jscomp/test/format_regression.js @@ -0,0 +1,85 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_exceptions = require("../runtime/caml_exceptions"); +var Caml_curry = require("../runtime/caml_curry"); + +function peek_queue() { + throw [ + 0, + Caml_exceptions.Assert_failure, + [ + 0, + "format_regression.ml", + 10, + 19 + ] + ]; +} + +function int_of_size() { + throw [ + 0, + Caml_exceptions.Assert_failure, + [ + 0, + "format_regression.ml", + 11, + 20 + ] + ]; +} + +function take_queue() { + throw [ + 0, + Caml_exceptions.Assert_failure, + [ + 0, + "format_regression.ml", + 12, + 19 + ] + ]; +} + +function format_pp_token(_, _$1) { + throw [ + 0, + Caml_exceptions.Assert_failure, + [ + 0, + "format_regression.ml", + 13, + 26 + ] + ]; +} + +var pp_infinity = 1000000010; + +function advance_loop(state) { + while(true) { + var match = peek_queue(state[4]); + var size = match[1]; + var size$1 = int_of_size(size); + if (size$1 < 0 && state[3] - state[2] < state[1]) { + 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]; + continue ; + + } + }; +} + +exports.peek_queue = peek_queue; +exports.int_of_size = int_of_size; +exports.take_queue = take_queue; +exports.format_pp_token = format_pp_token; +exports.pp_infinity = pp_infinity; +exports.advance_loop = advance_loop; +/* No side effect */ diff --git a/jscomp/test/format_regression.ml b/jscomp/test/format_regression.ml new file mode 100644 index 0000000000..f2eda86126 --- /dev/null +++ b/jscomp/test/format_regression.ml @@ -0,0 +1,41 @@ +[@@@warning"-20-21"] +type tag +type 'a queue_elem +type 'a queue = { + mutable insert : 'a queue_elem; + mutable body : 'a queue_elem; +} +type size +type pp_token +let peek_queue _ = assert false +let int_of_size _ = assert false +let take_queue _ = assert false +let format_pp_token _ _ = assert false +let pp_infinity = 1000000010;; +type pp_queue_elem = { + mutable elem_size : size; + token : pp_token; + length : int; +} + +type formatter = { + mutable pp_space_left : int; + mutable pp_left_total : int; + + mutable pp_right_total : int; + + mutable pp_queue : pp_queue_elem queue; +} +let rec advance_loop state = + match peek_queue state.pp_queue with + | {elem_size = size; token = tok; length = len} -> + let size = int_of_size size in + if not + (size < 0 && + (state.pp_right_total - state.pp_left_total < state.pp_space_left)) + then begin + ignore (take_queue state.pp_queue); + format_pp_token state (if size < 0 then pp_infinity else size) tok; + state.pp_left_total <- len + state.pp_left_total; + advance_loop state + end diff --git a/jscomp/test/inline_edge_cases.js b/jscomp/test/inline_edge_cases.js index cf0663b9c2..19a35df386 100644 --- a/jscomp/test/inline_edge_cases.js +++ b/jscomp/test/inline_edge_cases.js @@ -7,6 +7,8 @@ function test3(_n) { var n = _n; if (n) { _n = n - 1; + continue ; + } else { return n + 9; @@ -19,6 +21,8 @@ function test2(_n) { var n = _n; if (n) { _n = n - 1; + continue ; + } else { return test3(n) + 3; @@ -31,6 +35,8 @@ function test0(_n) { var n = _n; if (n) { _n = n - 1; + continue ; + } else { var _n$1 = n; @@ -38,6 +44,8 @@ function test0(_n) { var n$1 = _n$1; if (n$1) { _n$1 = n$1 - 1; + continue ; + } else { return test2(n$1) + 2; diff --git a/jscomp/test/inline_regression_test.js b/jscomp/test/inline_regression_test.js index 30b66ce4eb..7ae2c9a68a 100644 --- a/jscomp/test/inline_regression_test.js +++ b/jscomp/test/inline_regression_test.js @@ -19,6 +19,8 @@ function generic_basename(is_dir_sep, current_dir_name, name) { } else if (Caml_curry.app2(is_dir_sep, name, n)) { _n = n - 1; + continue ; + } else { var _n$1 = n; @@ -33,6 +35,8 @@ function generic_basename(is_dir_sep, current_dir_name, name) { } else { _n$1 = n$1 - 1; + continue ; + } }; } diff --git a/jscomp/test/int_map.js b/jscomp/test/int_map.js index ba94c25891..5501538d8f 100644 --- a/jscomp/test/int_map.js +++ b/jscomp/test/int_map.js @@ -148,6 +148,8 @@ function find(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -166,6 +168,8 @@ function mem(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return /* true */1; @@ -184,6 +188,8 @@ function min_binding(_param) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return [ @@ -206,6 +212,8 @@ function max_binding(_param) { var r = param[4]; if (r) { _param = r; + continue ; + } else { return [ @@ -280,6 +288,8 @@ function iter(f, _param) { iter(f, param[1]); Caml_curry.app2(f, param[2], param[3]); _param = param[4]; + continue ; + } else { return /* () */0; @@ -333,6 +343,8 @@ function fold(f, _m, _accu) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -347,6 +359,8 @@ function for_all(p, _param) { if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; + continue ; + } else { return /* false */0; @@ -374,6 +388,8 @@ function exists(p, _param) { } else { _param = param[4]; + continue ; + } } else { @@ -610,6 +626,8 @@ function cons_enum(_m, _e) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -637,6 +655,8 @@ function compare(cmp, m1, m2) { else { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } } } @@ -665,6 +685,8 @@ function equal(cmp, m1, m2) { if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } else { return /* false */0; @@ -711,6 +733,8 @@ function bindings_aux(_accu, _param) { ], bindings_aux(accu, param[4]) ]; + continue ; + } else { return accu; diff --git a/jscomp/test/lexer_test.js b/jscomp/test/lexer_test.js index 4070140785..47694ea629 100644 --- a/jscomp/test/lexer_test.js +++ b/jscomp/test/lexer_test.js @@ -26,6 +26,8 @@ function get_tokens(lex, str) { v, acc ]; + continue ; + } }; } diff --git a/jscomp/test/loop_regression_test.d.ts b/jscomp/test/loop_regression_test.d.ts new file mode 100644 index 0000000000..086d8246b7 --- /dev/null +++ b/jscomp/test/loop_regression_test.d.ts @@ -0,0 +1,3 @@ +export var f: (param : any) => any ; +export var suites: any ; + diff --git a/jscomp/test/loop_regression_test.js b/jscomp/test/loop_regression_test.js new file mode 100644 index 0000000000..204386fdbd --- /dev/null +++ b/jscomp/test/loop_regression_test.js @@ -0,0 +1,51 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Mt = require("./mt"); + +function f() { + var v = [ + 0, + 0 + ]; + var acc = [ + 0, + 0 + ]; + var n = 10; + while(true) { + if (v[1] > n) { + return acc[1]; + } + else { + acc[1] += v[1]; + ++ v[1]; + continue ; + + } + }; +} + +var suites_001 = [ + /* tuple */0, + "sum", + function () { + return [ + /* Eq */0, + 55, + f(/* () */0) + ]; + } +]; + +var suites = [ + /* :: */0, + suites_001, + /* [] */0 +]; + +Mt.from_pair_suites("loop_regression_test.ml", suites); + +exports.f = f; +exports.suites = suites; +/* Not a pure module */ diff --git a/jscomp/test/loop_regression_test.ml b/jscomp/test/loop_regression_test.ml new file mode 100644 index 0000000000..f47b8fc3d2 --- /dev/null +++ b/jscomp/test/loop_regression_test.ml @@ -0,0 +1,14 @@ + +let f () = + let v = ref 0 in + let acc = ref 0 in + + let rec loop n : int = + if !v > n then !acc else begin acc := !acc + !v ; incr v ; loop n end in + loop 10 + +let suites = Mt.[ + "sum", (fun _ -> Eq(55, f ())) + ] + +;; Mt.from_pair_suites __FILE__ suites diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index b29ecbf384..2bf4c52b43 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -140,6 +140,8 @@ function cons_enum(_m, _e) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -167,6 +169,8 @@ function compare(cmp, m1, m2) { else { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } } } @@ -195,6 +199,8 @@ function equal(cmp, m1, m2) { if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } else { return /* false */0; @@ -348,6 +354,8 @@ function find(x, _param) { var c = $$String.compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; diff --git a/jscomp/test/number_lexer.js b/jscomp/test/number_lexer.js index f5cceb1042..2db4ed1ec9 100644 --- a/jscomp/test/number_lexer.js +++ b/jscomp/test/number_lexer.js @@ -38,48 +38,50 @@ function __ocaml_lex_token_rec(l, lexbuf, ___ocaml_lex_state) { if (__ocaml_lex_state$1 > 9 || __ocaml_lex_state$1 < 0) { Caml_curry.app1(lexbuf[1], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } else { switch (__ocaml_lex_state$1) { case 0 : Caml_curry.app1(l, "new line"); ___ocaml_lex_state = 0; - break; - case 1 : + continue ; + case 1 : Caml_curry.app1(l, "number"); Caml_curry.app1(l, Lexing.lexeme(lexbuf)); ___ocaml_lex_state = 0; - break; - case 2 : + continue ; + case 2 : Caml_curry.app1(l, "ident"); Caml_curry.app1(l, Lexing.lexeme(lexbuf)); ___ocaml_lex_state = 0; - break; - case 3 : + continue ; + case 3 : Caml_curry.app1(l, "+"); ___ocaml_lex_state = 0; - break; - case 4 : + continue ; + case 4 : Caml_curry.app1(l, "-"); ___ocaml_lex_state = 0; - break; - case 5 : + continue ; + case 5 : Caml_curry.app1(l, "*"); ___ocaml_lex_state = 0; - break; - case 6 : + continue ; + case 6 : Caml_curry.app1(l, "/"); ___ocaml_lex_state = 0; - break; - case 7 : + continue ; + case 7 : Caml_curry.app1(l, "("); ___ocaml_lex_state = 0; - break; - case 8 : + continue ; + case 8 : Caml_curry.app1(l, ")"); ___ocaml_lex_state = 0; - break; - case 9 : + continue ; + case 9 : return Caml_curry.app1(l, "eof"); } diff --git a/jscomp/test/printf_test.d.ts b/jscomp/test/printf_test.d.ts index 9e94dea909..dd7660b912 100644 --- a/jscomp/test/printf_test.d.ts +++ b/jscomp/test/printf_test.d.ts @@ -1,3 +1,4 @@ export var print_pair: (fmt : any, param : any) => any ; export var suites: any ; +export var v: any ; diff --git a/jscomp/test/printf_test.js b/jscomp/test/printf_test.js index 30dd4ecade..d7f4c45150 100644 --- a/jscomp/test/printf_test.js +++ b/jscomp/test/printf_test.js @@ -68,27 +68,49 @@ var suites_002 = [ /* :: */0, [ /* tuple */0, - "print_pair", + "print_asprintf", function () { return [ /* Eq */0, - "(1,2)", - Caml_curry.app2(Format.asprintf([ - /* Format */0, - [ - /* Alpha */15, - /* End_of_format */0 - ], - "%a" - ]), print_pair, [ - /* tuple */0, - 1, - 2 + "xx", + Format.asprintf([ + /* Format */0, + [ + /* String_literal */11, + "xx", + /* End_of_format */0 + ], + "xx" ]) ]; } ], - /* [] */0 + [ + /* :: */0, + [ + /* tuple */0, + "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, + 1, + 2 + ]) + ]; + } + ], + /* [] */0 + ] ]; var suites = [ @@ -97,8 +119,19 @@ var suites = [ suites_002 ]; +var v = Format.asprintf([ + /* Format */0, + [ + /* String_literal */11, + "xx", + /* End_of_format */0 + ], + "xx" + ]); + Mt.from_pair_suites("printf_test.ml", suites); exports.print_pair = print_pair; exports.suites = suites; -/* Not a pure module */ +exports.v = v; +/* v Not a pure module */ diff --git a/jscomp/test/printf_test.ml b/jscomp/test/printf_test.ml index 1e44cd7f50..b224b2224b 100644 --- a/jscomp/test/printf_test.ml +++ b/jscomp/test/printf_test.ml @@ -3,8 +3,9 @@ let print_pair fmt (a,b) = Format.fprintf fmt "(%d,%d)" a b let suites = Mt.[ "sprintf_simple", (fun _ -> Eq("3232", Printf.sprintf "%s%d" "32" 32)); + "print_asprintf", (fun _ -> Eq("xx", Format.asprintf "xx" )); "print_pair", (fun _ -> Eq("(1,2)", Format.asprintf "%a" print_pair (1,2))) ] - +let v = Format.asprintf "xx" ;; Mt.from_pair_suites __FILE__ suites diff --git a/jscomp/test/qcc.js b/jscomp/test/qcc.js index f907e0b4bf..1cb3f45920 100644 --- a/jscomp/test/qcc.js +++ b/jscomp/test/qcc.js @@ -95,6 +95,8 @@ function find(s, _n) { } else { _n = n + 1; + continue ; + } }; } @@ -190,23 +192,31 @@ function skip(_param) { var match = Caml_curry.app1(getch, /* () */0); if (match !== 42) { _param$1 = /* () */0; + continue ; + } else if (peekch(/* () */0) === /* "/" */47) { return skip(Caml_curry.app1(getch, /* () */0)); } else { _param$1 = /* () */0; + continue ; + } }; } } else { _param = /* () */0; + continue ; + } } else if (ch >= 11) { if (ch >= 13) { _param = /* () */0; + continue ; + } else { return ch; @@ -214,6 +224,8 @@ function skip(_param) { } else if (ch >= 9) { _param = /* () */0; + continue ; + } else { return ch; @@ -258,6 +270,8 @@ function next() { } else { _n = 10 * n + Caml_curry.app1(getch, /* () */0) - 48; + continue ; + } }; } @@ -288,6 +302,8 @@ function next() { if (match$2 !== 34) { glo[e] = getq(/* () */0); _e = e + 1; + continue ; + } else { Caml_curry.app1(getch, /* () */0); @@ -311,6 +327,8 @@ function next() { if (isid(peekch(/* () */0))) { _ch = Caml_curry.app1(getch, /* () */0); _n$1 = n$1 + 1; + continue ; + } else { return [ @@ -376,6 +394,8 @@ function next() { } else { _param = param[2]; + continue ; + } } else { @@ -1088,6 +1108,8 @@ function binary(stk, lvl) { var loc$prime = test(lvl - 8, loc); binary(stk, lvl - 1); _loc = loc$prime; + continue ; + } else { Caml_curry.app1(unnext, t); @@ -1118,6 +1140,8 @@ function binary(stk, lvl) { List.iter(out, match[1]); } _param = /* () */0; + continue ; + } else { return Caml_curry.app1(unnext, t); @@ -1317,6 +1341,8 @@ function postfix(stk) { List.hd(rl), l ]; + continue ; + } }; }; @@ -1448,6 +1474,8 @@ function expr(stk) { out(4753665); } _param = /* () */0; + continue ; + } else { return Caml_curry.app1(unnext, t); @@ -1521,6 +1549,8 @@ function decl(g, _n, _stk) { Caml_curry.app1(next$1, /* () */0); _stk = stk$prime; _n = n$prime; + continue ; + } else { return [ @@ -1562,6 +1592,8 @@ function decl(g, _n, _stk) { } _stk = match[2]; _n = n + match[1]; + continue ; + } else { Caml_curry.app1(unnext, t); @@ -1783,6 +1815,8 @@ function top(_param) { else if (nextis(tokint)) { decl(/* true */1, 0, /* [] */0); _param = /* () */0; + continue ; + } else { var match = Caml_curry.app1(next$1, /* () */0); @@ -1837,8 +1871,8 @@ function top(_param) { _stk = stk$prime; _n = n + 1; _regs = List.tl(regs); - break; - + continue ; + } }; }; @@ -1908,6 +1942,8 @@ function top(_param) { ]), Caml_curry.app1(symstr, f)); } _param = /* () */0; + continue ; + } else { return Pervasives.failwith("[decl] or [fun] expected"); @@ -2073,6 +2109,8 @@ function elfgen(outf) { le(64, 1 + (n$1[1] << 32)); le(64, 0); _l = get32(l); + continue ; + } else { return 0; @@ -2310,6 +2348,8 @@ function main() { if (tok[0]) { ppsym(tok); _param = /* () */0; + continue ; + } else if (tok[1] === "EOF!") { return Printf.printf([ @@ -2325,6 +2365,8 @@ function main() { else { ppsym(tok); _param = /* () */0; + continue ; + } }; default: diff --git a/jscomp/test/rec_value_test.js b/jscomp/test/rec_value_test.js index 97b90d5e46..09869706c3 100644 --- a/jscomp/test/rec_value_test.js +++ b/jscomp/test/rec_value_test.js @@ -207,6 +207,8 @@ function even2(_n) { var n = _n; if (n) { _n = n - 1; + continue ; + } else { return /* true */1; @@ -234,6 +236,8 @@ function sum(_acc, _n) { if (n > 0) { _n = n - 1; _acc = acc + n; + continue ; + } else { return acc; diff --git a/jscomp/test/simple_lexer_test.js b/jscomp/test/simple_lexer_test.js index 463bd5bc0e..6f9020d6ea 100644 --- a/jscomp/test/simple_lexer_test.js +++ b/jscomp/test/simple_lexer_test.js @@ -32,6 +32,8 @@ function __ocaml_lex_translate_rec(lexbuf, ___ocaml_lex_state) { if (__ocaml_lex_state$1 > 2 || __ocaml_lex_state$1 < 0) { Caml_curry.app1(lexbuf[1], lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } else { switch (__ocaml_lex_state$1) { diff --git a/jscomp/test/small_inline_test.js b/jscomp/test/small_inline_test.js index 6866f66713..f4520950f2 100644 --- a/jscomp/test/small_inline_test.js +++ b/jscomp/test/small_inline_test.js @@ -31,6 +31,8 @@ function f(_x) { while(true) { var x = _x; _x = x + 4; + continue ; + }; } @@ -40,11 +42,14 @@ function ff(_x, _y) { var x = _x; _y = x + 1; _x = y; + continue ; + }; } function fff(_, _$1) { while(true) { + continue ; }; } diff --git a/jscomp/test/string_test.js b/jscomp/test/string_test.js index 5f7c0167e9..1532719905 100644 --- a/jscomp/test/string_test.js +++ b/jscomp/test/string_test.js @@ -76,6 +76,8 @@ function rev_split_by_char(c, s) { l ]; _i = i$prime + 1; + continue ; + } catch (exn){ if (exn === Caml_exceptions.Not_found) { @@ -133,6 +135,8 @@ function xsplit(delim, s) { ]; _i = i$prime; _l = l$2; + continue ; + } } diff --git a/jscomp/test/tailcall_inline_test.js b/jscomp/test/tailcall_inline_test.js index 0ea9dd56a7..57d42e4354 100644 --- a/jscomp/test/tailcall_inline_test.js +++ b/jscomp/test/tailcall_inline_test.js @@ -13,6 +13,8 @@ function f() { if (n > 0) { _n = n - 1; _acc = acc + n; + continue ; + } else { return acc; diff --git a/jscomp/test/test.mllib b/jscomp/test/test.mllib index 226c62fef9..77cd68fc7a 100644 --- a/jscomp/test/test.mllib +++ b/jscomp/test/test.mllib @@ -157,4 +157,6 @@ complex_if_test module_parameter_test regression_print global_exception_regression_test -printf_test \ No newline at end of file +printf_test +format_regression +loop_regression_test \ No newline at end of file diff --git a/jscomp/test/test_ari.js b/jscomp/test/test_ari.js index 6d1d9b04a2..827f1be8f8 100644 --- a/jscomp/test/test_ari.js +++ b/jscomp/test/test_ari.js @@ -39,6 +39,8 @@ function length_aux(_len, _param) { if (param) { _param = param[2]; _len = len + 1; + continue ; + } else { return len; diff --git a/jscomp/test/test_cps.js b/jscomp/test/test_cps.js index 59a4b4b603..0dea9f7e4b 100644 --- a/jscomp/test/test_cps.js +++ b/jscomp/test/test_cps.js @@ -16,6 +16,8 @@ function f(_n, _acc) { } }(n,acc)); _n = n - 1; + continue ; + } else { return Caml_curry.app1(acc, /* () */0); diff --git a/jscomp/test/test_fib.js b/jscomp/test/test_fib.js index 5ab33ec0d2..8d1f70e40a 100644 --- a/jscomp/test/test_fib.js +++ b/jscomp/test/test_fib.js @@ -89,6 +89,8 @@ function fib3(n) { _n = n$1 - 1; _b = a + b; _a = b; + continue ; + } else { return a; diff --git a/jscomp/test/test_for_map.js b/jscomp/test/test_for_map.js index 7588147186..5095b1ccf4 100644 --- a/jscomp/test/test_for_map.js +++ b/jscomp/test/test_for_map.js @@ -148,6 +148,8 @@ function find(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -166,6 +168,8 @@ function mem(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return /* true */1; @@ -184,6 +188,8 @@ function min_binding(_param) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return [ @@ -206,6 +212,8 @@ function max_binding(_param) { var r = param[4]; if (r) { _param = r; + continue ; + } else { return [ @@ -280,6 +288,8 @@ function iter(f, _param) { iter(f, param[1]); Caml_curry.app2(f, param[2], param[3]); _param = param[4]; + continue ; + } else { return /* () */0; @@ -333,6 +343,8 @@ function fold(f, _m, _accu) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -347,6 +359,8 @@ function for_all(p, _param) { if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; + continue ; + } else { return /* false */0; @@ -374,6 +388,8 @@ function exists(p, _param) { } else { _param = param[4]; + continue ; + } } else { @@ -610,6 +626,8 @@ function cons_enum(_m, _e) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -637,6 +655,8 @@ function compare(cmp, m1, m2) { else { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } } } @@ -665,6 +685,8 @@ function equal(cmp, m1, m2) { if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } else { return /* false */0; @@ -711,6 +733,8 @@ function bindings_aux(_accu, _param) { ], bindings_aux(accu, param[4]) ]; + continue ; + } else { return accu; diff --git a/jscomp/test/test_inline_map.js b/jscomp/test/test_inline_map.js index 2f6a5d3e2a..673c32b0a1 100644 --- a/jscomp/test/test_inline_map.js +++ b/jscomp/test/test_inline_map.js @@ -129,6 +129,8 @@ function find(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; diff --git a/jscomp/test/test_inline_map2.js b/jscomp/test/test_inline_map2.js index 9f82f65473..4a6d9fa1ec 100644 --- a/jscomp/test/test_inline_map2.js +++ b/jscomp/test/test_inline_map2.js @@ -130,6 +130,8 @@ function find(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -299,6 +301,8 @@ function find$1(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; diff --git a/jscomp/test/test_internalOO.js b/jscomp/test/test_internalOO.js index b0f5146ce7..3086bf2283 100644 --- a/jscomp/test/test_internalOO.js +++ b/jscomp/test/test_internalOO.js @@ -189,6 +189,8 @@ function find(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -207,6 +209,8 @@ function mem(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return /* true */1; @@ -225,6 +229,8 @@ function min_binding(_param) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return [ @@ -247,6 +253,8 @@ function max_binding(_param) { var r = param[4]; if (r) { _param = r; + continue ; + } else { return [ @@ -321,6 +329,8 @@ function iter(f, _param) { iter(f, param[1]); Caml_curry.app2(f, param[2], param[3]); _param = param[4]; + continue ; + } else { return /* () */0; @@ -374,6 +384,8 @@ function fold(f, _m, _accu) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -388,6 +400,8 @@ function for_all(p, _param) { if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; + continue ; + } else { return /* false */0; @@ -415,6 +429,8 @@ function exists(p, _param) { } else { _param = param[4]; + continue ; + } } else { @@ -651,6 +667,8 @@ function cons_enum(_m, _e) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -678,6 +696,8 @@ function compare(cmp, m1, m2) { else { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } } } @@ -708,6 +728,8 @@ function equal(cmp, m1, m2) { else if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } else { return /* false */0; @@ -750,6 +772,8 @@ function bindings_aux(_accu, _param) { ], bindings_aux(accu, param[4]) ]; + continue ; + } else { return accu; @@ -931,6 +955,8 @@ function find$1(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -949,6 +975,8 @@ function mem$1(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return /* true */1; @@ -967,6 +995,8 @@ function min_binding$1(_param) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return [ @@ -989,6 +1019,8 @@ function max_binding$1(_param) { var r = param[4]; if (r) { _param = r; + continue ; + } else { return [ @@ -1063,6 +1095,8 @@ function iter$1(f, _param) { iter$1(f, param[1]); Caml_curry.app2(f, param[2], param[3]); _param = param[4]; + continue ; + } else { return /* () */0; @@ -1116,6 +1150,8 @@ function fold$1(f, _m, _accu) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold$1(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -1130,6 +1166,8 @@ function for_all$1(p, _param) { if (Caml_curry.app2(p, param[2], param[3])) { if (for_all$1(p, param[1])) { _param = param[4]; + continue ; + } else { return /* false */0; @@ -1157,6 +1195,8 @@ function exists$1(p, _param) { } else { _param = param[4]; + continue ; + } } else { @@ -1393,6 +1433,8 @@ function cons_enum$1(_m, _e) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -1420,6 +1462,8 @@ function compare$1(cmp, m1, m2) { else { _e2 = cons_enum$1(e2[3], e2[4]); _e1 = cons_enum$1(e1[3], e1[4]); + continue ; + } } } @@ -1450,6 +1494,8 @@ function equal$1(cmp, m1, m2) { 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]); + continue ; + } else { return /* false */0; @@ -1492,6 +1538,8 @@ function bindings_aux$1(_accu, _param) { ], bindings_aux$1(accu, param[4]) ]; + continue ; + } else { return accu; @@ -1673,6 +1721,8 @@ function find$2(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -1691,6 +1741,8 @@ function mem$2(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return /* true */1; @@ -1709,6 +1761,8 @@ function min_binding$2(_param) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return [ @@ -1731,6 +1785,8 @@ function max_binding$2(_param) { var r = param[4]; if (r) { _param = r; + continue ; + } else { return [ @@ -1805,6 +1861,8 @@ function iter$2(f, _param) { iter$2(f, param[1]); Caml_curry.app2(f, param[2], param[3]); _param = param[4]; + continue ; + } else { return /* () */0; @@ -1858,6 +1916,8 @@ function fold$2(f, _m, _accu) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold$2(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -1872,6 +1932,8 @@ function for_all$2(p, _param) { if (Caml_curry.app2(p, param[2], param[3])) { if (for_all$2(p, param[1])) { _param = param[4]; + continue ; + } else { return /* false */0; @@ -1899,6 +1961,8 @@ function exists$2(p, _param) { } else { _param = param[4]; + continue ; + } } else { @@ -2135,6 +2199,8 @@ function cons_enum$2(_m, _e) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -2162,6 +2228,8 @@ function compare$2(cmp, m1, m2) { else { _e2 = cons_enum$2(e2[3], e2[4]); _e1 = cons_enum$2(e1[3], e1[4]); + continue ; + } } } @@ -2190,6 +2258,8 @@ function equal$2(cmp, m1, m2) { 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]); + continue ; + } else { return /* false */0; @@ -2236,6 +2306,8 @@ function bindings_aux$2(_accu, _param) { ], bindings_aux$2(accu, param[4]) ]; + continue ; + } else { return accu; @@ -2721,6 +2793,8 @@ function iter_f(obj, _param) { if (param) { Caml_curry.app1(param[1], obj); _param = param[2]; + continue ; + } else { return /* () */0; @@ -2796,6 +2870,8 @@ function lookup_keys(i, keys, tables) { } else if (tables$1[3] !== /* Empty */0) { _tables = tables$1[3]; + continue ; + } else { var next = [ diff --git a/jscomp/test/test_list.js b/jscomp/test/test_list.js index 05a89f1bc4..3b8dfc827f 100644 --- a/jscomp/test/test_list.js +++ b/jscomp/test/test_list.js @@ -14,6 +14,8 @@ function length_aux(_len, _param) { if (param) { _param = param[2]; _len = len + 1; + continue ; + } else { return len; @@ -57,6 +59,8 @@ function nth(l, n) { if (n$1) { _n = n$1 - 1; _l = l$1[2]; + continue ; + } else { return l$1[1]; @@ -80,6 +84,8 @@ function rev_append(_l1, _l2) { l2 ]; _l1 = l1[2]; + continue ; + } else { return l2; @@ -145,6 +151,8 @@ function rev_map(f, l) { Caml_curry.app1(f, param[1]), accu ]; + continue ; + } else { return accu; @@ -158,6 +166,8 @@ function iter(f, _param) { if (param) { Caml_curry.app1(f, param[1]); _param = param[2]; + continue ; + } else { return /* () */0; @@ -176,6 +186,8 @@ function iteri(f, l) { Caml_curry.app2(f$1, i, param[1]); _param = param[2]; _i = i + 1; + continue ; + } else { return /* () */0; @@ -190,6 +202,8 @@ function fold_left(f, _accu, _l) { if (l) { _l = l[2]; _accu = Caml_curry.app2(f, accu, l[1]); + continue ; + } else { return accu; @@ -245,6 +259,8 @@ function rev_map2(f, l1, l2) { Caml_curry.app2(f, l1$1[1], l2$1[1]), accu ]; + continue ; + } else { return Pervasives.invalid_arg("List.rev_map2"); @@ -268,6 +284,8 @@ function iter2(f, _l1, _l2) { Caml_curry.app2(f, l1[1], l2[1]); _l2 = l2[2]; _l1 = l1[2]; + continue ; + } else { return Pervasives.invalid_arg("List.iter2"); @@ -292,6 +310,8 @@ function fold_left2(f, _accu, _l1, _l2) { _l2 = l2[2]; _l1 = l1[2]; _accu = Caml_curry.app3(f, accu, l1[1], l2[1]); + continue ; + } else { return Pervasives.invalid_arg("List.fold_left2"); @@ -329,6 +349,8 @@ function for_all(p, _param) { if (param) { if (Caml_curry.app1(p, param[1])) { _param = param[2]; + continue ; + } else { return /* false */0; @@ -349,6 +371,8 @@ function exists(p, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -366,6 +390,8 @@ function for_all2(p, _l1, _l2) { if (Caml_curry.app2(p, l1[1], l2[1])) { _l2 = l2[2]; _l1 = l1[2]; + continue ; + } else { return /* false */0; @@ -396,6 +422,8 @@ function exists2(p, _l1, _l2) { else { _l2 = l2[2]; _l1 = l1[2]; + continue ; + } } else { @@ -417,6 +445,8 @@ function mem(x, _param) { if (param) { if (Caml_primitive.caml_compare(param[1], x)) { _param = param[2]; + continue ; + } else { return /* true */1; @@ -437,6 +467,8 @@ function memq(x, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -452,6 +484,8 @@ function assoc(x, _param) { var match = param[1]; if (Caml_primitive.caml_compare(match[1], x)) { _param = param[2]; + continue ; + } else { return match[2]; @@ -473,6 +507,8 @@ function assq(x, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -487,6 +523,8 @@ function mem_assoc(x, _param) { if (param) { if (Caml_primitive.caml_compare(param[1][1], x)) { _param = param[2]; + continue ; + } else { return /* true */1; @@ -507,6 +545,8 @@ function mem_assq(x, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -565,6 +605,8 @@ function find(p, _param) { } else { _param = param[2]; + continue ; + } } else { @@ -590,9 +632,13 @@ function find_all(p) { x, accu ]; + continue ; + } else { _param = l; + continue ; + } } else { @@ -620,6 +666,8 @@ function partition(p, l) { x, yes ]; + continue ; + } else { _param = l$1; @@ -628,6 +676,8 @@ function partition(p, l) { x, no ]; + continue ; + } } else { @@ -729,6 +779,8 @@ function chop(_k, _l) { if (l) { _l = l[2]; _k = k - 1; + continue ; + } else { throw [ @@ -928,6 +980,8 @@ function stable_sort(cmp, l) { accu ]; _l1 = l1[2]; + continue ; + } else { _accu = [ @@ -936,6 +990,8 @@ function stable_sort(cmp, l) { accu ]; _l2 = l2$1[2]; + continue ; + } } else { @@ -1127,6 +1183,8 @@ function stable_sort(cmp, l) { accu ]; _l1 = l1[2]; + continue ; + } else { _accu = [ @@ -1135,6 +1193,8 @@ function stable_sort(cmp, l) { accu ]; _l2 = l2$1[2]; + continue ; + } } else { @@ -1449,6 +1509,8 @@ function sort_uniq(cmp, l) { accu ]; _l1 = t1; + continue ; + } else { _accu = [ @@ -1457,6 +1519,8 @@ function sort_uniq(cmp, l) { accu ]; _l2 = t2; + continue ; + } } else { @@ -1467,6 +1531,8 @@ function sort_uniq(cmp, l) { ]; _l2 = t2; _l1 = t1; + continue ; + } } else { @@ -1771,6 +1837,8 @@ function sort_uniq(cmp, l) { accu ]; _l1 = t1; + continue ; + } else { _accu = [ @@ -1779,6 +1847,8 @@ function sort_uniq(cmp, l) { accu ]; _l2 = t2; + continue ; + } } else { @@ -1789,6 +1859,8 @@ function sort_uniq(cmp, l) { ]; _l2 = t2; _l1 = t1; + continue ; + } } else { diff --git a/jscomp/test/test_map_find.js b/jscomp/test/test_map_find.js index 887254548c..cebc9c5586 100644 --- a/jscomp/test/test_map_find.js +++ b/jscomp/test/test_map_find.js @@ -130,6 +130,8 @@ function find(x, _param) { var c = Caml_primitive.caml_int_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -299,6 +301,8 @@ function find$1(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; diff --git a/jscomp/test/test_order_tailcall.js b/jscomp/test/test_order_tailcall.js index a0db7d9b7c..366dd12318 100644 --- a/jscomp/test/test_order_tailcall.js +++ b/jscomp/test/test_order_tailcall.js @@ -4,6 +4,7 @@ function f(_, _$1) { while(true) { + continue ; }; } @@ -16,6 +17,8 @@ function f1(_x, _y, _z) { _z = x; _y = z; _x = y; + continue ; + }; } @@ -23,6 +26,8 @@ function f2(_, _y) { while(true) { var y = _y; _y = y + 10; + continue ; + }; } @@ -32,6 +37,8 @@ function f3(_x, _y) { var x = _x; _y = x + 10; _x = y; + continue ; + }; } @@ -41,6 +48,8 @@ function f4(_x, _y) { var x = _x; _y = y + x; _x = x + 10; + continue ; + }; } @@ -49,6 +58,8 @@ function f5(_x, _y, z) { var y = _y; _y = z + 20; _x = y + 10; + continue ; + }; } @@ -57,10 +68,13 @@ function f6(b) { if (b) { if (b) { if (b) { - if (!b) { + if (b) { + continue ; + + } + else { return /* false */0; } - } else { return /* false */0; @@ -90,7 +104,10 @@ function f7(b) { else if (b) { return /* true */1; } - + else { + continue ; + + } }; } @@ -100,12 +117,18 @@ function f8(_x, _y) { var x = _x; if (x > 10) { _y = y + 1; + continue ; + } else if (x < 5) { _x = x - 1; + continue ; + } else if (x > 6) { _x = x - 2; + continue ; + } else { return f8(x, y + 1) + f8(x - 1, y); diff --git a/jscomp/test/test_per.js b/jscomp/test/test_per.js index 49456da75e..3a92f2ef87 100644 --- a/jscomp/test/test_per.js +++ b/jscomp/test/test_per.js @@ -145,6 +145,8 @@ function valid_float_lexem(s) { } else { _i = i + 1; + continue ; + } } else if (match !== 45) { @@ -152,6 +154,8 @@ function valid_float_lexem(s) { } else { _i = i + 1; + continue ; + } } }; @@ -236,6 +240,8 @@ function flush_all() { } _param = param[2]; + continue ; + } else { return /* () */0; @@ -354,6 +360,8 @@ function unsafe_really_input(ic, s, _ofs, _len) { if (r) { _len = len - r; _ofs = ofs + r; + continue ; + } else { throw Caml_exceptions.End_of_file; @@ -392,6 +400,8 @@ function input_line(chan) { Caml_string.caml_blit_string(hd, 0, buf, pos - len, len); _param = param[2]; _pos = pos - len; + continue ; + } else { return buf; @@ -430,6 +440,8 @@ function input_line(chan) { beg, accu ]; + continue ; + } } else if (accu) { diff --git a/jscomp/test/test_react.js b/jscomp/test/test_react.js index 7bdd258af0..43aeb815be 100644 --- a/jscomp/test/test_react.js +++ b/jscomp/test/test_react.js @@ -18,7 +18,7 @@ ReactDom.render(React.createClass({ "alt": "pic" }, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!"), React.DOM.h3(null, "type safe!")); } - }), Caml_curry.app1(document.getElementById, "hi")); + }), document.getElementById("hi")); var u = 33; diff --git a/jscomp/test/test_seq.js b/jscomp/test/test_seq.js index 2c302eb117..71a2fdc2bd 100644 --- a/jscomp/test/test_seq.js +++ b/jscomp/test/test_seq.js @@ -34,6 +34,8 @@ function assoc3(x, _l) { } else { _l = l[2]; + continue ; + } } else { diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index aa9f523199..8e53b86d7d 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -160,6 +160,8 @@ function Make(Ord) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return param[2]; @@ -177,6 +179,8 @@ function Make(Ord) { var r = param[3]; if (r) { _param = r; + continue ; + } else { return param[2]; @@ -287,6 +291,8 @@ function Make(Ord) { var c = Caml_curry.app2(Ord[1], x, param[2]); if (c) { _param = c < 0 ? param[1] : param[3]; + continue ; + } else { return /* true */1; @@ -409,6 +415,8 @@ function Make(Ord) { e ]; _s = s[1]; + continue ; + } else { return e; @@ -428,6 +436,8 @@ function Make(Ord) { else { _e2 = cons_enum(e2[2], e2[3]); _e1 = cons_enum(e1[2], e1[3]); + continue ; + } } else { @@ -470,6 +480,8 @@ function Make(Ord) { 0 ], l2)) { _s1 = r1; + continue ; + } else { return /* false */0; @@ -483,6 +495,8 @@ function Make(Ord) { 0 ], r2)) { _s1 = l1; + continue ; + } else { return /* false */0; @@ -491,6 +505,8 @@ function Make(Ord) { else if (subset(l1, l2)) { _s2 = r2; _s1 = r1; + continue ; + } else { return /* false */0; @@ -512,6 +528,8 @@ function Make(Ord) { iter(f, param[1]); Caml_curry.app1(f, param[2]); _param = param[3]; + continue ; + } else { return /* () */0; @@ -525,6 +543,8 @@ function Make(Ord) { if (s) { _accu = Caml_curry.app2(f, s[2], fold(f, s[1], accu)); _s = s[3]; + continue ; + } else { return accu; @@ -538,6 +558,8 @@ function Make(Ord) { if (Caml_curry.app1(p, param[2])) { if (for_all(p, param[1])) { _param = param[3]; + continue ; + } else { return /* false */0; @@ -564,6 +586,8 @@ function Make(Ord) { } else { _param = param[3]; + continue ; + } } else { @@ -640,6 +664,8 @@ function Make(Ord) { param[2], elements_aux(accu, param[3]) ]; + continue ; + } else { return accu; @@ -657,6 +683,8 @@ function Make(Ord) { var c = Caml_curry.app2(Ord[1], x, v); if (c) { _param = c < 0 ? param[1] : param[3]; + continue ; + } else { return v; diff --git a/jscomp/test/test_simple_tailcall.js b/jscomp/test/test_simple_tailcall.js index d84f7593a2..2f03e8d890 100644 --- a/jscomp/test/test_simple_tailcall.js +++ b/jscomp/test/test_simple_tailcall.js @@ -4,6 +4,7 @@ function tailcall() { while(true) { + continue ; }; } @@ -29,6 +30,8 @@ function length(_acc, _x) { else { _x = tl; _acc = acc + 1; + continue ; + } } else { diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index 3b76f86b4f..dbf4ede9e8 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -128,6 +128,8 @@ function find(x, _param) { var c = Caml_string.caml_string_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 11534bbee4..ba1c93a188 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -51,6 +51,8 @@ function split(delim, s) { ]; _i = i$prime; _l = l$2; + continue ; + } } @@ -279,6 +281,8 @@ function find(x, _param) { var c = Caml_primitive.caml_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return param[3]; @@ -297,6 +301,8 @@ function mem(x, _param) { var c = Caml_primitive.caml_compare(x, param[2]); if (c) { _param = c < 0 ? param[1] : param[4]; + continue ; + } else { return /* true */1; @@ -315,6 +321,8 @@ function min_binding(_param) { var l = param[1]; if (l) { _param = l; + continue ; + } else { return [ @@ -337,6 +345,8 @@ function max_binding(_param) { var r = param[4]; if (r) { _param = r; + continue ; + } else { return [ @@ -411,6 +421,8 @@ function iter(f, _param) { iter(f, param[1]); Caml_curry.app2(f, param[2], param[3]); _param = param[4]; + continue ; + } else { return /* () */0; @@ -464,6 +476,8 @@ function fold(f, _m, _accu) { if (m) { _accu = Caml_curry.app3(f, m[2], m[3], fold(f, m[1], accu)); _m = m[4]; + continue ; + } else { return accu; @@ -478,6 +492,8 @@ function for_all(p, _param) { if (Caml_curry.app2(p, param[2], param[3])) { if (for_all(p, param[1])) { _param = param[4]; + continue ; + } else { return /* false */0; @@ -505,6 +521,8 @@ function exists(p, _param) { } else { _param = param[4]; + continue ; + } } else { @@ -741,6 +759,8 @@ function cons_enum(_m, _e) { e ]; _m = m[1]; + continue ; + } else { return e; @@ -768,6 +788,8 @@ function compare(cmp, m1, m2) { else { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } } } @@ -798,6 +820,8 @@ function equal(cmp, m1, m2) { else if (Caml_curry.app2(cmp, e1[2], e2[2])) { _e2 = cons_enum(e2[3], e2[4]); _e1 = cons_enum(e1[3], e1[4]); + continue ; + } else { return /* false */0; @@ -840,6 +864,8 @@ function bindings_aux(_accu, _param) { ], bindings_aux(accu, param[4]) ]; + continue ; + } else { return accu; @@ -940,6 +966,8 @@ function compute_update_sequences(all_tickers) { ticker, up ]; + continue ; + } else { var l = find(ticker_name, map); @@ -1185,6 +1213,8 @@ function loop(_lines, _param) { if (lines) { _param = process_input_line(param[2], all_tickers, lines[1]); _lines = lines[2]; + continue ; + } else { return print_all_composite(all_tickers); From 5f00a09f86d7255a6d58a4165d1a2d8d0b8f6f9a Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Sun, 7 Feb 2016 21:33:45 -0500 Subject: [PATCH 5/5] fix config renaming --- jscomp/js_config.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jscomp/js_config.ml b/jscomp/js_config.ml index 421ffc6100..442d52430d 100644 --- a/jscomp/js_config.ml +++ b/jscomp/js_config.ml @@ -97,7 +97,7 @@ let runtime_set = String_set.of_list [ "caml_utils.js"; "caml_exceptions.js"; (* "caml_io.js"; *) - "curry.js"; + "caml_curry.js"; "caml_file.js"; "caml_lexer.js"; "caml_string.js"