├── api └── dune ├── VERSION ├── examples ├── wiki │ ├── main.mli │ ├── wiki_syntax.ml │ ├── wikicreole.mll │ ├── dune │ ├── index.html │ └── test.ml ├── cubes │ ├── cubes.mli │ ├── index.html │ └── dune ├── planet │ ├── planet.mli │ ├── texture.jpg │ ├── dune │ └── index.html ├── webgl │ ├── webgldemo.mli │ └── dune ├── wysiwyg │ ├── main.mli │ ├── dune │ └── index.html ├── minesweeper │ ├── main.mli │ ├── README │ ├── sprites │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ ├── 8.png │ │ ├── bomb.png │ │ ├── flag.png │ │ ├── empty.png │ │ └── normal.png │ ├── dune │ ├── index.html │ └── LICENSE ├── boulderdash │ ├── boulderdash.mli │ ├── README │ ├── sprites │ │ ├── D.png │ │ ├── L.png │ │ ├── R.png │ │ ├── U.png │ │ ├── bD.png │ │ ├── bL.png │ │ ├── bR.png │ │ ├── bU.png │ │ ├── bam.png │ │ ├── bomb.png │ │ ├── door.png │ │ ├── end.png │ │ ├── guy.png │ │ ├── wall.png │ │ ├── boulder.png │ │ ├── diamond.png │ │ ├── empty.png │ │ ├── grass.png │ │ ├── push_l.png │ │ ├── push_r.png │ │ ├── blue_diamond.png │ │ └── red_diamond.png │ ├── maps │ │ ├── level0.map │ │ ├── level3.map │ │ ├── level1.map │ │ ├── level2.map │ │ └── level4.map │ ├── maps.txt │ ├── index.html │ ├── dune │ └── LICENSE ├── graph_viewer │ ├── viewer_js.mli │ ├── index.html │ ├── dune │ ├── dot_render.mli │ ├── dot_lexer.mli │ └── viewer.mli ├── hyperbolic │ ├── hypertree.mli │ ├── icons │ │ ├── favicon.png │ │ ├── info-38.png │ │ ├── commons-38.png │ │ ├── globe-38.png │ │ ├── wikipedia-38.png │ │ └── meeting-point-38.png │ ├── thumbnails │ │ ├── alces.jpg │ │ ├── bison.jpg │ │ ├── bos.jpg │ │ ├── camel.jpg │ │ ├── canis.jpg │ │ ├── capra.jpg │ │ ├── felis.jpg │ │ ├── homo.jpg │ │ ├── koala.jpg │ │ ├── lama.jpg │ │ ├── lemur.jpg │ │ ├── lepus.jpg │ │ ├── lutra.jpg │ │ ├── lynx.jpg │ │ ├── mus.jpg │ │ ├── oryx.jpg │ │ ├── pan.jpg │ │ ├── pongo.jpg │ │ ├── sorex.jpg │ │ ├── sus.jpg │ │ ├── talpa.jpg │ │ ├── ursus.jpg │ │ ├── ateles.jpg │ │ ├── castor.jpg │ │ ├── cervus.jpg │ │ ├── echidne.jpg │ │ ├── eliomys.jpg │ │ ├── giraffa.jpg │ │ ├── gorilla.jpg │ │ ├── hystrix.jpg │ │ ├── macaca.jpg │ │ ├── marmota.jpg │ │ ├── monodon.jpg │ │ ├── mouflon.jpg │ │ ├── mouton.jpg │ │ ├── okapia.jpg │ │ ├── orcinus.jpg │ │ ├── ovibos.jpg │ │ ├── procyon.jpg │ │ ├── sciurus.jpg │ │ ├── tarsius.jpg │ │ ├── vulpes.jpg │ │ ├── acinonyx.jpg │ │ ├── aepyceros.jpg │ │ ├── ailuropoda.jpg │ │ ├── bradypus.jpg │ │ ├── callitrix.jpg │ │ ├── capreolus.jpg │ │ ├── erinaceus.jpg │ │ ├── lamantins.jpg │ │ ├── loxodonta.jpg │ │ ├── macropus.jpg │ │ ├── mephitis.jpg │ │ ├── mirounga.jpg │ │ ├── neofelis.jpg │ │ ├── odobenus.jpg │ │ ├── panthera.jpg │ │ ├── parahyaena.jpg │ │ ├── phocoena.jpg │ │ ├── plecotus.jpg │ │ ├── priodontes.jpg │ │ ├── rupicapra.jpg │ │ ├── simocyon.jpg │ │ ├── suricata.jpg │ │ ├── synaptomys.jpg │ │ ├── syncerus.jpg │ │ ├── tremarctos.jpg │ │ ├── balaenoptera.jpg │ │ ├── connochaetes.jpg │ │ ├── equus_asinus.jpg │ │ ├── equus_grevyi.jpg │ │ ├── hippopotamus.jpg │ │ ├── mesocricetus.jpg │ │ ├── myrmecophaga.jpg │ │ ├── phacochoerus.jpg │ │ ├── rhinolophus.jpg │ │ ├── arctocephalus.jpg │ │ ├── ceratotherium.jpg │ │ ├── delphinapterus.jpg │ │ ├── equus_caballus.jpg │ │ ├── ornithorynque.jpg │ │ └── platacanthomys.jpg │ ├── messages.json │ └── dune ├── separate_compilation │ ├── bin.reference │ ├── module1.ml │ ├── lib1_mod2.ml │ ├── module2.ml │ ├── lib1_mod1.ml │ └── index.html ├── dune ├── ocsigen8-100x30.png ├── test_wheel │ ├── dune │ └── index.html ├── graphics │ ├── dune │ ├── main.ml │ └── index.html ├── namespace │ ├── for-node.expected │ ├── a.ml │ └── b.ml └── README.md ├── compiler ├── tests-num │ ├── .ocamlformat │ ├── main.ml │ └── dune ├── tests-re │ ├── .ocamlformat │ └── dune ├── tests-ocaml │ ├── .ocamlformat │ ├── lib-set │ │ ├── testmap.reference │ │ ├── testset.reference │ │ └── dune │ ├── lib-bool │ │ ├── test.reference │ │ └── dune │ ├── lib-filename │ │ ├── extension.reference │ │ ├── suffix.reference │ │ ├── extension.ml │ │ ├── dune │ │ └── suffix.ml │ ├── lib-fun │ │ ├── test.reference │ │ └── dune │ ├── lib-int │ │ ├── test.reference │ │ └── dune │ ├── lib-int64 │ │ ├── test.reference │ │ ├── issue9460.reference │ │ └── dune │ ├── lib-list │ │ ├── test.reference │ │ └── dune │ ├── lib-option │ │ ├── test.reference │ │ └── dune │ ├── lib-queue │ │ ├── test.reference │ │ └── dune │ ├── lib-result │ │ ├── test.reference │ │ └── dune │ ├── lib-seq │ │ ├── test.reference │ │ └── dune │ ├── lib-stack │ │ ├── test.reference │ │ └── dune │ ├── lib-uchar │ │ ├── test.reference │ │ └── dune │ ├── lib-effects │ │ ├── manylive.reference │ │ ├── marshal.reference │ │ ├── partial.reference │ │ ├── test1.reference │ │ ├── test10.reference │ │ ├── test4.reference │ │ ├── test5.reference │ │ ├── overflow.reference │ │ ├── test11.reference │ │ ├── used_cont.reference │ │ ├── cmphash.reference │ │ ├── sched.reference │ │ ├── evenodd.reference │ │ ├── test6.reference │ │ ├── test3.reference │ │ ├── test_lazy.reference │ │ ├── unhandled_unlinked.reference │ │ ├── shallow_state.reference │ │ ├── shallow_state_io.reference │ │ ├── unhandled_unlinked.ml │ │ ├── test2.reference │ │ ├── reperform.reference │ │ ├── effects.reference │ │ ├── test1.ml │ │ ├── evenodd.ml │ │ ├── test3.ml │ │ ├── test4.ml │ │ ├── used_cont.ml │ │ ├── test11.ml │ │ ├── test5.ml │ │ ├── test6.ml │ │ ├── marshal.ml │ │ ├── partial.ml │ │ ├── manylive.ml │ │ ├── test2.ml │ │ ├── cmphash.ml │ │ ├── test10.ml │ │ └── overflow.ml │ ├── lib-random │ │ ├── selfinit.reference │ │ ├── defaultinit.reference │ │ ├── defaultinit.ml │ │ ├── selfinit.ml │ │ └── testvectors.ml │ ├── lib-digest │ │ ├── md5.reference │ │ └── dune │ ├── lib-bytes-utf │ │ ├── test.reference │ │ └── dune │ ├── lib-bigarray │ │ ├── pr5115.reference │ │ ├── weak_bigarray.reference │ │ ├── change_layout.reference │ │ ├── fftba.reference │ │ ├── pr5115.ml │ │ └── weak_bigarray.ml │ ├── prim-revapply │ │ ├── revapply.reference │ │ ├── apply.reference │ │ ├── revapply.ml │ │ ├── dune │ │ └── apply.ml │ ├── dune │ ├── lib-format │ │ ├── pr6824.reference │ │ ├── print_seq.reference │ │ ├── print_if_newline.reference │ │ ├── pr6824.ml │ │ ├── print_if_newline.ml │ │ └── print_seq.ml │ ├── lib-bytes │ │ ├── test_bytes.reference │ │ └── dune │ ├── prim-bswap │ │ ├── bswap.reference │ │ ├── dune │ │ └── bswap.ml │ ├── lib-str │ │ ├── t01.reference │ │ └── dune │ ├── lib-string │ │ ├── test_string.reference │ │ └── dune │ ├── prim-bigstring │ │ ├── bigstring_access.reference │ │ ├── string_access.reference │ │ └── dune │ ├── lib-atomic │ │ └── dune │ ├── lib-printf │ │ ├── pr6534.reference │ │ └── pr6534.ml │ ├── lib-floatarray │ │ └── dune │ ├── lib-float │ │ └── dune │ ├── lib-buffer │ │ ├── dune │ │ └── test.reference │ ├── basic-modules │ │ ├── dune │ │ └── recursive_module_init.reference │ └── lib-hashtbl │ │ ├── hfun.reference │ │ ├── htbl.reference │ │ └── dune ├── tests-sourcemap │ ├── a.ml │ ├── b.ml │ ├── c.ml │ ├── d.ml │ ├── test.ml │ ├── dump.reference │ └── dune ├── tests-check-prim │ ├── main.ml │ └── unix.ml ├── tests-dynlink │ ├── export │ ├── main.out.expected │ ├── plugin.ml │ ├── main.ml │ └── dune ├── tests-compiler │ ├── gen-rules │ │ └── dune │ ├── util │ │ └── dune │ ├── dune │ └── es6.ml ├── tests-dynlink-js │ ├── main.out.expected │ ├── plugin.ml │ ├── main.ml │ └── dune ├── tests-jsoo │ ├── calc_input.txt │ ├── bin │ │ ├── error1.expected │ │ ├── error1-unregister.expected │ │ ├── error2-unregister.expected │ │ ├── error2.expected │ │ ├── error3.ml │ │ ├── error2.ml │ │ ├── error1.ml │ │ ├── error1.html │ │ ├── error2.html │ │ ├── error3.html │ │ ├── error1-unregister.html │ │ ├── error2-unregister.html │ │ └── error3-unregister.html │ ├── lib-effects │ │ ├── README.md │ │ └── dune │ ├── runtime.js │ ├── lexer_1307.mll │ ├── parser_1307.mly │ ├── flush_stubs.c │ ├── dune │ ├── calc_lexer.mll │ ├── calc_parser.mly │ └── gh_1307.ml ├── lib-runtime-files │ ├── gen │ │ └── dune │ ├── tests │ │ └── dune │ └── dune ├── lib-cmdline │ └── dune ├── ppx │ ├── dune │ └── properties.ml ├── lib │ ├── .ocamlformat-ignore │ ├── lambda_lifting.mli │ ├── js_assign.mli │ ├── annot_lexer.mli │ ├── effects.mli │ ├── reserved.mli │ └── timer.mli ├── tests-toplevel │ ├── test_toplevel.reference │ ├── test_toplevel.ml │ └── dune ├── tests-runtime-events │ ├── test_runtime_events.ml │ └── dune ├── lib-findlib-support │ ├── dune │ └── jsoo_findlib_support.mli ├── tests-js-parser │ └── dune ├── lib-dynlink │ ├── dune │ └── js_of_ocaml_compiler_dynlink.mli ├── bin-jsoo_minify │ ├── dune │ └── jsoo_minify.mli ├── tests-full │ └── dune ├── bin-js_of_ocaml │ ├── js_of_ocaml.mli │ ├── findlib_support.empty.ml │ ├── link.mli │ ├── build_fs.mli │ ├── build_runtime.mli │ └── print_runtime.mli └── tests-io │ └── cat.ml ├── lib ├── tests │ ├── gen-rules │ │ └── dune │ ├── test_json.ml │ └── dune ├── gen_stubs │ └── dune ├── lwt │ ├── dune │ ├── log │ │ └── dune │ └── graphics │ │ ├── dune │ │ └── graphics_js_stubs.c ├── deriving_json │ ├── tests │ │ └── dune │ └── dune ├── tyxml │ └── dune ├── runtime │ └── dune └── js_of_ocaml │ ├── dune │ └── js_of_ocaml_stubs.c ├── ppx ├── ppx_deriving_json │ ├── lib │ │ ├── .ocamlformat-ignore │ │ └── dune │ └── tests │ │ └── main.ml └── ppx_js │ ├── tests │ ├── main.ml │ └── dune │ ├── lib_internal │ ├── dune │ └── ppx_js_internal.mli │ ├── bin │ ├── dune │ └── main.ml │ ├── lib │ ├── dune │ ├── ppx_js_rewriter.ml │ └── ppx_js_rewriter.mli │ └── as-lib │ ├── dune │ └── ppx_js.ml ├── benchmarks ├── sources │ ├── ml │ │ ├── loop.ml │ │ └── dune │ └── js │ │ ├── fib.js │ │ └── loop.js ├── report-size-effects.config ├── report-js.config ├── report-time-effects.config ├── report-nativejs.config ├── utils │ └── remove_comments.pl ├── report-size-bzip2-effects.config ├── report-size-gzipped-effects.config ├── dune ├── report-time.config ├── report-size.config ├── report-time-optim.config ├── run.config ├── report-size-optim.config └── report-compiletime.config ├── tools ├── version │ ├── gen │ │ ├── dune │ │ └── gen.ml │ └── dune ├── select │ └── dune ├── sourcemap │ └── dune ├── format-js.sh ├── toplevel_expect │ └── dune └── emacs-format-js.el ├── toplevel ├── examples │ ├── lwt_toplevel │ │ ├── ppx_support.disabled.ml │ │ ├── graphics_support.disabled.ml │ │ ├── graphics_support.enabled.ml │ │ ├── ocp_indent.fake.ml │ │ ├── indent.mli │ │ ├── ppx_support.enabled.ml │ │ ├── test_dynlink.ml │ │ ├── colorize.mli │ │ ├── ocp_indent.ok.ml │ │ ├── effects_flags.ml │ │ └── colorize.fake.ml │ ├── server │ │ └── dune │ └── eval │ │ ├── dune │ │ └── index.html ├── bin │ └── dune ├── lib │ ├── dune │ ├── js_of_ocaml_toplevel.ml │ └── jsooTopError.mli └── test │ ├── test_toplevel.reference │ ├── test_toplevel.ml │ └── dune ├── .gitattributes ├── .git-blame-ignore-revs ├── manual ├── files │ └── performances │ │ ├── size.png │ │ ├── time.png │ │ ├── nativejs.png │ │ ├── size-optim.png │ │ ├── time-optim.png │ │ ├── compiletime.png │ │ ├── size-effects.png │ │ ├── time-effects.png │ │ └── size-bzip2-effects.png ├── dune └── install.wiki ├── .github ├── ISSUE_TEMPLATE │ ├── other.md │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── changelog.yml ├── js_of_ocaml.opam.template ├── js_of_ocaml-lwt.opam.template ├── js_of_ocaml-ppx.opam.template ├── js_of_ocaml-tyxml.opam.template ├── js_of_ocaml-compiler.opam.template ├── js_of_ocaml-toplevel.opam.template ├── js_of_ocaml-ppx_deriving_json.opam.template ├── .ocamlformat ├── CODE_OF_CONDUCT.md ├── runtime ├── dune └── sync.js ├── dune-workspace.dev ├── HACKING.md ├── dune ├── Makefile └── .gitignore /api/dune: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 5.2.0 2 | -------------------------------------------------------------------------------- /examples/wiki/main.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/cubes/cubes.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/planet/planet.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/webgl/webgldemo.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/wysiwyg/main.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/minesweeper/main.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/tests-num/.ocamlformat: -------------------------------------------------------------------------------- 1 | disable -------------------------------------------------------------------------------- /compiler/tests-re/.ocamlformat: -------------------------------------------------------------------------------- 1 | disable -------------------------------------------------------------------------------- /examples/boulderdash/boulderdash.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/graph_viewer/viewer_js.mli: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/.ocamlformat: -------------------------------------------------------------------------------- 1 | disable -------------------------------------------------------------------------------- /examples/hyperbolic/hypertree.mli: -------------------------------------------------------------------------------- 1 | (* *) 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-set/testmap.reference: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-set/testset.reference: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bool/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-filename/extension.reference: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-filename/suffix.reference: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-fun/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-int/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-int64/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-list/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-option/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-queue/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-result/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-seq/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-stack/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-uchar/test.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /compiler/tests-sourcemap/a.ml: -------------------------------------------------------------------------------- 1 | let f x = x + 1 2 | -------------------------------------------------------------------------------- /compiler/tests-sourcemap/b.ml: -------------------------------------------------------------------------------- 1 | let f x = x - 1 2 | -------------------------------------------------------------------------------- /compiler/tests-sourcemap/c.ml: -------------------------------------------------------------------------------- 1 | let f x = B.f x * 2 2 | -------------------------------------------------------------------------------- /compiler/tests-sourcemap/d.ml: -------------------------------------------------------------------------------- 1 | let f x = x / 2 2 | -------------------------------------------------------------------------------- /compiler/tests-check-prim/main.ml: -------------------------------------------------------------------------------- 1 | (* this is empty *) 2 | -------------------------------------------------------------------------------- /compiler/tests-check-prim/unix.ml: -------------------------------------------------------------------------------- 1 | (* this is empty *) 2 | -------------------------------------------------------------------------------- /compiler/tests-dynlink/export: -------------------------------------------------------------------------------- 1 | Stdlib 2 | Stdlib__Buffer -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/manylive.reference: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/marshal.reference: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/partial.reference: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test1.reference: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test10.reference: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test4.reference: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test5.reference: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-int64/issue9460.reference: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /lib/tests/gen-rules/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name gen)) 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/overflow.reference: -------------------------------------------------------------------------------- 1 | 211 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test11.reference: -------------------------------------------------------------------------------- 1 | 10 2 | 42 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/used_cont.reference: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-random/selfinit.reference: -------------------------------------------------------------------------------- 1 | PASSED 2 | -------------------------------------------------------------------------------- /compiler/tests-dynlink/main.out.expected: -------------------------------------------------------------------------------- 1 | hello 2 | plugin loaded 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/cmphash.reference: -------------------------------------------------------------------------------- 1 | ok 2 | ok 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/sched.reference: -------------------------------------------------------------------------------- 1 | A+,+B.C,D,[]!E. 2 | -------------------------------------------------------------------------------- /compiler/tests-compiler/gen-rules/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name gen)) 3 | -------------------------------------------------------------------------------- /compiler/tests-dynlink-js/main.out.expected: -------------------------------------------------------------------------------- 1 | hello 2 | plugin loaded 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-digest/md5.reference: -------------------------------------------------------------------------------- 1 | Test vectors passed. 2 | -------------------------------------------------------------------------------- /ppx/ppx_deriving_json/lib/.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | ppx_deriving_json.cppo.ml -------------------------------------------------------------------------------- /benchmarks/sources/ml/loop.ml: -------------------------------------------------------------------------------- 1 | for _ = 1 to 1000000000 do 2 | () 3 | done 4 | -------------------------------------------------------------------------------- /compiler/tests-dynlink-js/plugin.ml: -------------------------------------------------------------------------------- 1 | let () = print_endline "plugin loaded" 2 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/calc_input.txt: -------------------------------------------------------------------------------- 1 | 1+2*3 2 | (1+2)*3 3 | -10-1 4 | 63/2*-3 5 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bytes-utf/test.reference: -------------------------------------------------------------------------------- 1 | All UTF tests passed! 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/evenodd.reference: -------------------------------------------------------------------------------- 1 | even 100000 is true 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test6.reference: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | true 4 | -------------------------------------------------------------------------------- /tools/version/gen/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name gen) 3 | (libraries unix)) 4 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/ppx_support.disabled.ml: -------------------------------------------------------------------------------- 1 | let init () = () 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ml linguist-language=OCaml 2 | *.mli linguist-language=OCaml 3 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error1.expected: -------------------------------------------------------------------------------- 1 | Fatal error: exception custom printer 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bigarray/pr5115.reference: -------------------------------------------------------------------------------- 1 | ***EXEC*** 2 | ***EXEC*** 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test3.reference: -------------------------------------------------------------------------------- 1 | in handler. raising X 2 | 10 3 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/graphics_support.disabled.ml: -------------------------------------------------------------------------------- 1 | let init _ = () 2 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # ocamlformat bump 2 | 3c98cd3e0c4e1191983b602a8e38a1c92d259891 -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test_lazy.reference: -------------------------------------------------------------------------------- 1 | 1000 2 | 2000 3 | Undefined 4 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-revapply/revapply.reference: -------------------------------------------------------------------------------- 1 | 6 2 | 36 3 | 18 4 | 37 5 | 260 6 | -------------------------------------------------------------------------------- /ppx/ppx_js/tests/main.ml: -------------------------------------------------------------------------------- 1 | let () = Toplevel_expect_test.run (fun _ -> Ppx_js.mapper) 2 | -------------------------------------------------------------------------------- /examples/boulderdash/README: -------------------------------------------------------------------------------- 1 | This is a port of the Boulder Dash example from O'Browser. 2 | -------------------------------------------------------------------------------- /examples/minesweeper/README: -------------------------------------------------------------------------------- 1 | This is a port of the Minesweeper example from O'Browser. 2 | -------------------------------------------------------------------------------- /tools/select/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names select) 3 | (preprocess no_preprocessing)) 4 | -------------------------------------------------------------------------------- /examples/separate_compilation/bin.reference: -------------------------------------------------------------------------------- 1 | hello world! 2 | hello 3 | Lib1_mod1 was linked 4 | -------------------------------------------------------------------------------- /lib/gen_stubs/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name gen_stubs) 3 | (libraries compiler-libs.common)) 4 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/dune: -------------------------------------------------------------------------------- 1 | (env 2 | (_ 3 | (flags 4 | (:standard -w -27-32-33-35-39-50-60)))) 5 | -------------------------------------------------------------------------------- /compiler/tests-sourcemap/test.ml: -------------------------------------------------------------------------------- 1 | exception Int of int 2 | 3 | let () = raise (Int (Testlib.B.f 2)) 4 | -------------------------------------------------------------------------------- /examples/dune: -------------------------------------------------------------------------------- 1 | (alias 2 | (name default) 3 | (deps 4 | index.html 5 | (glob_files *.{png}))) 6 | -------------------------------------------------------------------------------- /lib/tests/test_json.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/lib/tests/test_json.ml -------------------------------------------------------------------------------- /compiler/lib-runtime-files/gen/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name gen) 3 | (libraries js_of_ocaml-compiler)) 4 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/graphics_support.enabled.ml: -------------------------------------------------------------------------------- 1 | let init elt = Graphics_js.open_canvas elt 2 | -------------------------------------------------------------------------------- /toplevel/examples/server/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names server) 3 | (libraries findlib cohttp-lwt-unix)) 4 | -------------------------------------------------------------------------------- /compiler/lib-cmdline/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsoo_cmdline) 3 | (libraries cmdliner js_of_ocaml-compiler)) 4 | -------------------------------------------------------------------------------- /compiler/tests-dynlink/plugin.ml: -------------------------------------------------------------------------------- 1 | let () = print_endline "plugin loaded" 2 | 3 | let b = Buffer.create 18 4 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/lib-effects/README.md: -------------------------------------------------------------------------------- 1 | Most tests come from https://github.com/ocaml-multicore/effects-examples -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/unhandled_unlinked.reference: -------------------------------------------------------------------------------- 1 | Fatal error: exception Effect.Unhandled 2 | 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-format/pr6824.reference: -------------------------------------------------------------------------------- 1 | [1] 2 | [2] 3 | [1] 4 | [2] 5 | 6 | All tests succeeded. 7 | -------------------------------------------------------------------------------- /examples/planet/texture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/planet/texture.jpg -------------------------------------------------------------------------------- /compiler/tests-dynlink/main.ml: -------------------------------------------------------------------------------- 1 | let () = print_endline "hello" 2 | 3 | let () = Dynlink.loadfile "./plugin.cmo" 4 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error1-unregister.expected: -------------------------------------------------------------------------------- 1 | Fatal error: exception Dune__exe__Error1.D(2, "test", _) 2 | 3 | -------------------------------------------------------------------------------- /examples/ocsigen8-100x30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/ocsigen8-100x30.png -------------------------------------------------------------------------------- /examples/wiki/wiki_syntax.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/wiki/wiki_syntax.ml -------------------------------------------------------------------------------- /examples/wiki/wikicreole.mll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/wiki/wikicreole.mll -------------------------------------------------------------------------------- /compiler/tests-jsoo/runtime.js: -------------------------------------------------------------------------------- 1 | //Provides: flush_stdout_stderr 2 | function flush_stdout_stderr(_unit) { return 0 } 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bigarray/weak_bigarray.reference: -------------------------------------------------------------------------------- 1 | a.(0) = 42.000000 2 | b.(0) = 42.000000 3 | b.(0) = 42.000000 4 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/shallow_state.reference: -------------------------------------------------------------------------------- 1 | Initial state: 0 2 | Updated state: 42 3 | Final state: 43 4 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/shallow_state_io.reference: -------------------------------------------------------------------------------- 1 | Initial state: 0 2 | Updated state: 42 3 | Final state: 43 4 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/ocp_indent.fake.ml: -------------------------------------------------------------------------------- 1 | let indent s _in_lines = s 2 | 3 | (* ocp-indent not available *) 4 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/lexer_1307.mll: -------------------------------------------------------------------------------- 1 | { 2 | open Parser_1307 3 | } 4 | 5 | rule token = parse 6 | | _ { TOKEN } 7 | | eof { EOF } -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bytes/test_bytes.reference: -------------------------------------------------------------------------------- 1 | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 | All tests succeeded. 3 | -------------------------------------------------------------------------------- /examples/boulderdash/sprites/D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/D.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/L.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/L.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/R.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/R.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/U.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/U.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/bD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/bD.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/bL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/bL.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/bR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/bR.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/bU.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/bU.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/1.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/2.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/3.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/4.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/5.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/6.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/7.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/8.png -------------------------------------------------------------------------------- /manual/files/performances/size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/size.png -------------------------------------------------------------------------------- /manual/files/performances/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/time.png -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/indent.mli: -------------------------------------------------------------------------------- 1 | open Js_of_ocaml 2 | 3 | val textarea : Dom_html.textAreaElement Js.t -> unit 4 | -------------------------------------------------------------------------------- /compiler/ppx/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ppx_optcomp_light) 3 | (libraries compiler-libs.common ppxlib) 4 | (kind ppx_rewriter)) 5 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-bswap/bswap.reference: -------------------------------------------------------------------------------- 1 | 4433 2 | f0f0 3 | 44332211 4 | f0f0f0f0 5 | 8877665544332211 6 | f0f0f0f0f0f0f0f0 7 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-revapply/apply.reference: -------------------------------------------------------------------------------- 1 | 6 2 | 36 3 | 18 4 | 37 5 | 260 6 | 6 7 | 36 8 | 18 9 | 37 10 | 260 11 | -------------------------------------------------------------------------------- /examples/boulderdash/sprites/bam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/bam.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/bomb.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/door.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/door.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/end.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/guy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/guy.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/wall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/wall.png -------------------------------------------------------------------------------- /examples/hyperbolic/icons/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/icons/favicon.png -------------------------------------------------------------------------------- /examples/hyperbolic/icons/info-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/icons/info-38.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/bomb.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/flag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/flag.png -------------------------------------------------------------------------------- /examples/separate_compilation/module1.ml: -------------------------------------------------------------------------------- 1 | let hello_string = "hello" 2 | 3 | let hello name = Printf.printf "hello %s!\n" name 4 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/ppx_support.enabled.ml: -------------------------------------------------------------------------------- 1 | let init () = Ast_mapper.register "js_of_ocaml" (fun _ -> Ppx_js.mapper) 2 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-format/print_seq.reference: -------------------------------------------------------------------------------- 1 | empty 2 | 0 3 | misc 4 | 1 2 3 5 | end of tests 6 | 7 | All tests succeeded. 8 | -------------------------------------------------------------------------------- /examples/boulderdash/sprites/boulder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/boulder.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/diamond.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/diamond.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/empty.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/grass.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/push_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/push_l.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/push_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/push_r.png -------------------------------------------------------------------------------- /examples/hyperbolic/icons/commons-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/icons/commons-38.png -------------------------------------------------------------------------------- /examples/hyperbolic/icons/globe-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/icons/globe-38.png -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/alces.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/alces.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/bison.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/bison.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/bos.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/bos.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/camel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/camel.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/canis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/canis.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/capra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/capra.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/felis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/felis.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/homo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/homo.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/koala.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/koala.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/lama.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/lama.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/lemur.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/lemur.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/lepus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/lepus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/lutra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/lutra.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/lynx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/lynx.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/mus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/mus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/oryx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/oryx.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/pan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/pan.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/pongo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/pongo.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/sorex.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/sorex.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/sus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/sus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/talpa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/talpa.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/ursus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/ursus.jpg -------------------------------------------------------------------------------- /examples/minesweeper/sprites/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/empty.png -------------------------------------------------------------------------------- /examples/minesweeper/sprites/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/minesweeper/sprites/normal.png -------------------------------------------------------------------------------- /manual/files/performances/nativejs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/nativejs.png -------------------------------------------------------------------------------- /manual/files/performances/size-optim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/size-optim.png -------------------------------------------------------------------------------- /manual/files/performances/time-optim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/time-optim.png -------------------------------------------------------------------------------- /compiler/lib/.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | annot_lexer.ml 2 | annot_parser.ml 3 | annot_parser.mli 4 | js_lexer.ml 5 | js_parser.ml 6 | js_parser.mli 7 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error2-unregister.expected: -------------------------------------------------------------------------------- 1 | Fatal error: exception Match_failure("compiler/tests-jsoo/bin/error2.ml", 13, 2) 2 | 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-str/t01.reference: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/compiler/tests-ocaml/lib-str/t01.reference -------------------------------------------------------------------------------- /examples/hyperbolic/icons/wikipedia-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/icons/wikipedia-38.png -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/ateles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/ateles.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/castor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/castor.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/cervus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/cervus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/echidne.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/echidne.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/eliomys.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/eliomys.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/giraffa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/giraffa.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/gorilla.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/gorilla.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/hystrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/hystrix.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/macaca.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/macaca.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/marmota.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/marmota.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/monodon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/monodon.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/mouflon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/mouflon.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/mouton.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/mouton.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/okapia.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/okapia.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/orcinus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/orcinus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/ovibos.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/ovibos.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/procyon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/procyon.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/sciurus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/sciurus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/tarsius.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/tarsius.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/vulpes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/vulpes.jpg -------------------------------------------------------------------------------- /manual/files/performances/compiletime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/compiletime.png -------------------------------------------------------------------------------- /manual/files/performances/size-effects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/size-effects.png -------------------------------------------------------------------------------- /manual/files/performances/time-effects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/time-effects.png -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/test_dynlink.ml: -------------------------------------------------------------------------------- 1 | let _ = print_endline "Dynlink OK" 2 | 3 | let f () = print_endline "Test_dynlink.f Ok" 4 | -------------------------------------------------------------------------------- /benchmarks/report-size-effects.config: -------------------------------------------------------------------------------- 1 | histogramref sizes "" js_of_ocaml/generated #fbaf4f direct 2 | histogram sizes "" effects #fb4f4f effects 3 | -------------------------------------------------------------------------------- /compiler/tests-compiler/util/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsoo_compiler_expect_tests_helper) 3 | (libraries js_of_ocaml_compiler unix str sedlex)) 4 | -------------------------------------------------------------------------------- /examples/boulderdash/sprites/blue_diamond.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/blue_diamond.png -------------------------------------------------------------------------------- /examples/boulderdash/sprites/red_diamond.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/boulderdash/sprites/red_diamond.png -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/acinonyx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/acinonyx.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/aepyceros.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/aepyceros.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/ailuropoda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/ailuropoda.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/bradypus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/bradypus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/callitrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/callitrix.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/capreolus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/capreolus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/erinaceus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/erinaceus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/lamantins.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/lamantins.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/loxodonta.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/loxodonta.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/macropus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/macropus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/mephitis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/mephitis.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/mirounga.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/mirounga.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/neofelis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/neofelis.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/odobenus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/odobenus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/panthera.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/panthera.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/parahyaena.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/parahyaena.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/phocoena.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/phocoena.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/plecotus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/plecotus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/priodontes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/priodontes.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/rupicapra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/rupicapra.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/simocyon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/simocyon.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/suricata.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/suricata.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/synaptomys.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/synaptomys.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/syncerus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/syncerus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/tremarctos.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/tremarctos.jpg -------------------------------------------------------------------------------- /benchmarks/report-js.config: -------------------------------------------------------------------------------- 1 | histogramref times node js_of_ocaml #d98e2d compiled to JS (node) 2 | histogram times node js #d9112d native JS (node) 3 | -------------------------------------------------------------------------------- /benchmarks/report-time-effects.config: -------------------------------------------------------------------------------- 1 | histogramref times node js_of_ocaml #fbaf4f default 2 | histogram times node effects #fb4f4f --enable=effects 3 | -------------------------------------------------------------------------------- /examples/hyperbolic/icons/meeting-point-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/icons/meeting-point-38.png -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/balaenoptera.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/balaenoptera.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/connochaetes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/connochaetes.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/equus_asinus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/equus_asinus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/equus_grevyi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/equus_grevyi.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/hippopotamus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/hippopotamus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/mesocricetus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/mesocricetus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/myrmecophaga.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/myrmecophaga.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/phacochoerus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/phacochoerus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/rhinolophus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/rhinolophus.jpg -------------------------------------------------------------------------------- /examples/separate_compilation/lib1_mod2.ml: -------------------------------------------------------------------------------- 1 | let hi () = print_endline "hi" 2 | 3 | let () = at_exit (fun () -> print_endline "Lib1_mod2 was linked") 4 | -------------------------------------------------------------------------------- /examples/separate_compilation/module2.ml: -------------------------------------------------------------------------------- 1 | let () = try raise Not_found with Not_found -> Module1.hello "world" 2 | 3 | let () = Lib1_mod1.hello () 4 | -------------------------------------------------------------------------------- /benchmarks/report-nativejs.config: -------------------------------------------------------------------------------- 1 | histogram times node js #775588 native JS (node) 2 | histogramref times node js_of_ocaml #fbaf4f compiled to JS (node) 3 | -------------------------------------------------------------------------------- /benchmarks/utils/remove_comments.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | $/ = undef; 3 | $_ = <>; 4 | s#\(\*[^*]*\*+([^)*][^*]*\*+)*\)#defined $2 ? $2 : ""#gse; 5 | print; 6 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error2.expected: -------------------------------------------------------------------------------- 1 | Fatal error: exception File "compiler/tests-jsoo/bin/error2.ml", line 13, characters 2-7: Pattern matching failed 2 | -------------------------------------------------------------------------------- /examples/boulderdash/maps/level0.map: -------------------------------------------------------------------------------- 1 | ################### 2 | #S........+.......# 3 | #+....+.........+## 4 | #...+........+.#.E# 5 | ################### 6 | -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/arctocephalus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/arctocephalus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/ceratotherium.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/ceratotherium.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/delphinapterus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/delphinapterus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/equus_caballus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/equus_caballus.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/ornithorynque.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/ornithorynque.jpg -------------------------------------------------------------------------------- /examples/hyperbolic/thumbnails/platacanthomys.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/examples/hyperbolic/thumbnails/platacanthomys.jpg -------------------------------------------------------------------------------- /examples/separate_compilation/lib1_mod1.ml: -------------------------------------------------------------------------------- 1 | let hello () = print_endline "hello" 2 | 3 | let () = at_exit (fun () -> print_endline "Lib1_mod1 was linked") 4 | -------------------------------------------------------------------------------- /examples/test_wheel/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test_wheel) 3 | (libraries js_of_ocaml) 4 | (modes js) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | -------------------------------------------------------------------------------- /manual/files/performances/size-bzip2-effects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbuenzli/js_of_ocaml/master/manual/files/performances/size-bzip2-effects.png -------------------------------------------------------------------------------- /lib/lwt/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name js_of_ocaml_lwt) 3 | (public_name js_of_ocaml-lwt) 4 | (libraries js_of_ocaml lwt) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | -------------------------------------------------------------------------------- /benchmarks/report-size-bzip2-effects.config: -------------------------------------------------------------------------------- 1 | histogramref sizes "" js_of_ocaml/bzip2 #fbaf4f direct (bzip2) 2 | histogram sizes "" effects/bzip2 #fb4f4f effects (bzip2) 3 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/unhandled_unlinked.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | exit_status= "2" 3 | *) 4 | 5 | open Effect 6 | type _ t += E : unit t 7 | let _ = perform E 8 | -------------------------------------------------------------------------------- /benchmarks/report-size-gzipped-effects.config: -------------------------------------------------------------------------------- 1 | histogramref sizes "" js_of_ocaml/gzipped #fbaf4f direct (gzip) 2 | histogram sizes "" effects/gzipped #fb4f4f effects (gzip) 3 | -------------------------------------------------------------------------------- /benchmarks/sources/js/fib.js: -------------------------------------------------------------------------------- 1 | function fib(n) { 2 | return (n < 2)?1:(fib(n-1) + fib(n-2)); 3 | } 4 | 5 | var n = 40; 6 | 7 | if (fib(n) !== 165580141) throw "error!"; 8 | -------------------------------------------------------------------------------- /compiler/tests-num/main.ml: -------------------------------------------------------------------------------- 1 | include Test_nats 2 | include Test_big_ints 3 | include Test_ratios 4 | include Test_nums 5 | include Test_io 6 | 7 | let () = Test.end_tests () 8 | -------------------------------------------------------------------------------- /benchmarks/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names report run stripdebug) 3 | (libraries unix compiler-libs.bytecomp)) 4 | 5 | (alias 6 | (name default) 7 | (deps report.exe run.exe)) 8 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bigarray/change_layout.reference: -------------------------------------------------------------------------------- 1 | Generic rank test: Ok 2 | Scalar test: Ok 3 | Rank-1 array test: Ok 4 | Rank-2 array test: Ok 5 | Rank-3 array test: Ok 6 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test2.reference: -------------------------------------------------------------------------------- 1 | perform effect (E 0) 2 | caught effect (E 0). continuing.. 3 | perform returns 1 4 | done 2 5 | continue returns 3 6 | result=4 7 | -------------------------------------------------------------------------------- /compiler/tests-toplevel/test_toplevel.reference: -------------------------------------------------------------------------------- 1 | hello 2 | Line 3, characters 2-4: 3 | Error: Syntax error 4 | Line 4, characters 0-16: 5 | Error: Unbound module Missing_module 6 | -------------------------------------------------------------------------------- /ppx/ppx_js/lib_internal/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ppx_js_internal) 3 | (libraries compiler-libs.common ppxlib) 4 | (kind ppx_rewriter) 5 | (preprocess 6 | (pps ppxlib.metaquot))) 7 | -------------------------------------------------------------------------------- /compiler/lib-runtime-files/tests/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsoo_lib_runtime_test) 3 | (libraries js_of_ocaml-compiler.runtime-files) 4 | (inline_tests) 5 | (preprocess 6 | (pps ppx_expect))) 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Other 3 | about: Anything that is neither a bug report nor a feature request 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-format/print_if_newline.reference: -------------------------------------------------------------------------------- 1 | 2 | test print_if_newline 3 | newline here 4 | this gets printed 5 | print_if_newline doesn't crash when last statement 6 | newline here 7 | -------------------------------------------------------------------------------- /ppx/ppx_js/bin/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names main) 3 | (libraries ppx_js ppxlib)) 4 | 5 | (install 6 | (section lib) 7 | (package js_of_ocaml-ppx) 8 | (files 9 | (main.exe as ppx_js))) 10 | -------------------------------------------------------------------------------- /compiler/ppx/properties.ml: -------------------------------------------------------------------------------- 1 | let table : (string, string) Hashtbl.t = Hashtbl.create 17 2 | 3 | let set k v = Hashtbl.add table k v 4 | 5 | let get k = try Some (Hashtbl.find table k) with Not_found -> None 6 | -------------------------------------------------------------------------------- /examples/boulderdash/maps/level3.map: -------------------------------------------------------------------------------- 1 | ############## 2 | #XXXX# # 3 | #XXX+# + # 4 | #X..S# X## # 5 | #+ +X+# # 6 | # #X#X# # 7 | # +E.... # 8 | # #++ # 9 | ############## 10 | -------------------------------------------------------------------------------- /compiler/tests-runtime-events/test_runtime_events.ml: -------------------------------------------------------------------------------- 1 | module RE = Runtime_events 2 | 3 | type RE.User.tag += MyTag 4 | 5 | let ev = RE.User.register "my_event" MyTag RE.Type.unit 6 | 7 | let () = RE.User.write ev () 8 | -------------------------------------------------------------------------------- /examples/boulderdash/maps/level1.map: -------------------------------------------------------------------------------- 1 | ################## 2 | #S X # # 3 | # + #.X..XX....# 4 | # X #.+..++....# 5 | # + # + # 6 | # # XX # 7 | # . +. E# 8 | ################## 9 | -------------------------------------------------------------------------------- /ppx/ppx_js/lib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ppx_js_rewriter) 3 | (public_name js_of_ocaml-ppx) 4 | (synopsis "Js_of_ocaml ppx") 5 | (libraries ppx_js) 6 | (ppx_runtime_libraries js_of_ocaml) 7 | (kind ppx_rewriter)) 8 | -------------------------------------------------------------------------------- /benchmarks/report-time.config: -------------------------------------------------------------------------------- 1 | histogram times "" opt #729fcf ocamlopt 2 | histogram times "" byte #204a87 ocamlc 3 | histogramref times node js_of_ocaml #fbaf4f node 4 | histogram times sm js_of_ocaml #fb4f4f SpiderMonkey 5 | -------------------------------------------------------------------------------- /lib/deriving_json/tests/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name deriving_expect_tests) 3 | (libraries unix js_of_ocaml js_of_ocaml.deriving) 4 | (inline_tests 5 | (modes js)) 6 | (preprocess 7 | (pps ppx_expect ppx_deriving_json))) 8 | -------------------------------------------------------------------------------- /tools/sourcemap/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names jsoo_sourcemap) 3 | (libraries 4 | js_of_ocaml-compiler 5 | compiler-libs.common 6 | js_of_ocaml-compiler.findlib-support) 7 | (flags 8 | (:standard -safe-string))) 9 | -------------------------------------------------------------------------------- /compiler/lib-findlib-support/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsoo_findlib_support) 3 | (libraries js_of_ocaml-compiler findlib) 4 | (optional) 5 | (public_name js_of_ocaml-compiler.findlib-support) 6 | (library_flags (-linkall))) 7 | -------------------------------------------------------------------------------- /js_of_ocaml.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-string/test_string.reference: -------------------------------------------------------------------------------- 1 | -- Hashtbl.hash raw_string: 240a0e56 2 | -- String.unseeded_hash raw_string: 240a0e56 3 | -- Hashtbl.seeded_hash 16 raw_string: 3210af30 4 | -- String.hash 16 raw_string: 3210af30 5 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-bigstring/bigstring_access.reference: -------------------------------------------------------------------------------- 1 | 1234 12 0 2 | fedc fe 0 3 | 12345678 123456 1234 4 | fedcba09 fedcba fedc 5 | 1234567890abcdef 1234567890abcd 1234567890ab 6 | fedcba0987654321 fedcba09876543 fedcba098765 7 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-bigstring/string_access.reference: -------------------------------------------------------------------------------- 1 | 1234 12 0 2 | fedc fe 0 3 | 12345678 123456 1234 4 | fedcba09 fedcba fedc 5 | 1234567890abcdef 1234567890abcd 1234567890ab 6 | fedcba0987654321 fedcba09876543 fedcba098765 7 | -------------------------------------------------------------------------------- /examples/boulderdash/maps/level2.map: -------------------------------------------------------------------------------- 1 | #################### 2 | #S# XXXXX # 3 | # # XX .XXX. # 4 | # # .XX. .X. # 5 | # # +. + # 6 | # ## XX # 7 | # +X. E# 8 | #################### 9 | -------------------------------------------------------------------------------- /js_of_ocaml-lwt.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | -------------------------------------------------------------------------------- /js_of_ocaml-ppx.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | -------------------------------------------------------------------------------- /js_of_ocaml-tyxml.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-atomic/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test_atomic) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (alias runtest) 8 | (deps test_atomic.bc.js) 9 | (action 10 | (run node test_atomic.bc.js))) 11 | -------------------------------------------------------------------------------- /examples/graphics/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (modes js) 4 | (libraries js_of_ocaml-lwt.graphics) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (alias 9 | (name default) 10 | (deps main.bc.js index.html)) 11 | -------------------------------------------------------------------------------- /js_of_ocaml-compiler.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | -------------------------------------------------------------------------------- /js_of_ocaml-toplevel.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | -------------------------------------------------------------------------------- /lib/deriving_json/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name js_of_ocaml_deriving) 3 | (public_name js_of_ocaml.deriving) 4 | (synopsis "Runtime library for the class Json.") 5 | (libraries) 6 | (wrapped false)) 7 | 8 | (ocamllex deriving_Json_lexer) 9 | -------------------------------------------------------------------------------- /manual/dune: -------------------------------------------------------------------------------- 1 | (rule 2 | (target dune.inc) 3 | (mode promote) 4 | (action 5 | (with-stdout-to 6 | %{target} 7 | (run ./gen_dune_inc.exe)))) 8 | 9 | (executable 10 | (name gen_dune_inc)) 11 | 12 | (include dune.inc) 13 | -------------------------------------------------------------------------------- /benchmarks/sources/js/loop.js: -------------------------------------------------------------------------------- 1 | for (var i = 1; i <= 1000000000; i++) {}; 2 | //for (var i = 1;;) {i=i+1|0; if (i <= 1000000000) continue; break;}; 3 | //for (var i = 1; i <= 1000000000; i=i+1|0) {}; 4 | //for (var i = 1; i <= 1000000000; i=i+1) {}; 5 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bigarray/fftba.reference: -------------------------------------------------------------------------------- 1 | 16... ok 2 | 32... ok 3 | 64... ok 4 | 128... ok 5 | 256... ok 6 | 512... ok 7 | 1024... ok 8 | 2048... ok 9 | 4096... ok 10 | 8192... ok 11 | 16384... ok 12 | 32768... ok 13 | 65536... ok 14 | -------------------------------------------------------------------------------- /js_of_ocaml-ppx_deriving_json.opam.template: -------------------------------------------------------------------------------- 1 | build: [ 2 | ["dune" "subst"] {dev} 3 | [ 4 | "dune" 5 | "build" 6 | "-p" 7 | name 8 | "-j" 9 | jobs 10 | "@install" 11 | "@doc" {with-doc} 12 | ] 13 | ] 14 | -------------------------------------------------------------------------------- /lib/lwt/log/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name lwt_log_js) 3 | (public_name js_of_ocaml-lwt.logger) 4 | (synopsis "Lwt logger for js_of_ocaml.") 5 | (optional) 6 | (libraries js_of_ocaml lwt lwt_log.core) 7 | (preprocess 8 | (pps js_of_ocaml-ppx))) 9 | -------------------------------------------------------------------------------- /lib/tyxml/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name js_of_ocaml_tyxml) 3 | (public_name js_of_ocaml-tyxml) 4 | (synopsis "Tyxml for js_of_ocaml.") 5 | (libraries js_of_ocaml tyxml tyxml.functor react reactiveData) 6 | (preprocess 7 | (pps js_of_ocaml-ppx))) 8 | -------------------------------------------------------------------------------- /compiler/tests-dynlink-js/main.ml: -------------------------------------------------------------------------------- 1 | let () = print_endline "hello" 2 | 3 | let require s = 4 | let open Js_of_ocaml in 5 | Js.Unsafe.fun_call (Js.Unsafe.js_expr "require") [| Js.Unsafe.inject (Js.string s) |] 6 | 7 | let () = require "./plugin.js" 8 | -------------------------------------------------------------------------------- /compiler/tests-js-parser/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name run) 3 | (libraries js_of_ocaml_compiler unix str)) 4 | 5 | ;; $ git clone git@github.com:tc39/test262-parser-tests.git 6 | ;; $ dune exe compiler/tests-js-parser/run.exe test262-parser-tests/pass/* 7 | -------------------------------------------------------------------------------- /examples/boulderdash/maps.txt: -------------------------------------------------------------------------------- 1 | "maps/level0.map" "Level without boulders" 2 | "maps/level1.map" "Simple falls" 3 | "maps/level2.map" "More falls" 4 | "maps/level3.map" "Real (yet little) puzzle" 5 | "maps/level4.map" "Bigger puzzle (copie de BeeDeeDash)" 6 | -------------------------------------------------------------------------------- /examples/namespace/for-node.expected: -------------------------------------------------------------------------------- 1 | A 2 | A 3 | B 4 | OK 5 | OK 6 | OK 7 | OK 8 | OK 9 | OK 10 | OK 11 | OK 12 | OK 13 | A 14 | OK 15 | OK 16 | OK 17 | OK 18 | OK 19 | OK 20 | OK 21 | OK 22 | OK 23 | OK 24 | OK 25 | OK 26 | OK 27 | OK 28 | OK 29 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/parser_1307.mly: -------------------------------------------------------------------------------- 1 | 2 | %{ 3 | 4 | %} 5 | 6 | %token EOF 7 | %token TOKEN 8 | %start root 9 | %type root 10 | %% 11 | 12 | root: 13 | | expr EOF { 0 } 14 | | expr error root { 1 } 15 | 16 | expr: 17 | TOKEN TOKEN { 1 } 18 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-printf/pr6534.reference: -------------------------------------------------------------------------------- 1 | 1 [ foo] 2 | 2 [ foo] 3 | 3 [foo ] 4 | 4 [foo ] 5 | 5 [foo ] 6 | 6 [foo ] 7 | 1 [ "foo"] 8 | 2 [ "foo"] 9 | 3 ["foo" ] 10 | 4 ["foo" ] 11 | 5 ["foo" ] 12 | 6 ["foo" ] 13 | 14 | All tests succeeded. 15 | -------------------------------------------------------------------------------- /examples/test_wheel/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | test_wheel 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /benchmarks/report-size.config: -------------------------------------------------------------------------------- 1 | histogram sizes "" ml #488f31 Source 2 | histogram sizes "" byte #83b170 Bytecode 3 | histogramref sizes "" js_of_ocaml/full #e6d589 Runtime 4 | 5 | histogram blank 6 | histogram blank 7 | histogram sizes "" js_of_ocaml/generated #e48f54 Generated code -------------------------------------------------------------------------------- /examples/namespace/a.ml: -------------------------------------------------------------------------------- 1 | let () = print_endline "A" 2 | 3 | exception Exn 4 | 5 | let try_with f = try f () with Exn -> () 6 | 7 | let raise_ () = raise Exn 8 | 9 | let () = Js_of_ocaml.Js.export "tryWith" try_with 10 | 11 | let () = Js_of_ocaml.Js.export "raise" raise_ 12 | -------------------------------------------------------------------------------- /examples/namespace/b.ml: -------------------------------------------------------------------------------- 1 | let () = print_endline "B" 2 | 3 | exception Exn 4 | 5 | let try_with f = try f () with Exn -> () 6 | 7 | let raise_ () = raise Exn 8 | 9 | let () = Js_of_ocaml.Js.export "tryWith" try_with 10 | 11 | let () = Js_of_ocaml.Js.export "raise" raise_ 12 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/reperform.reference: -------------------------------------------------------------------------------- 1 | [5 2 | [4 3 | [3 4 | [2 5 | [1 6 | 1] 7 | 2] 8 | 3] 9 | 4] 10 | 5] 11 | = 142 12 | [5 13 | [4 14 | [3 15 | [2 16 | [1 17 | !1] 18 | !2] 19 | !3] 20 | !4] 21 | !5] 22 | Stdlib.Effect.Unhandled(Dune__exe__Reperform.E(42)) 23 | -------------------------------------------------------------------------------- /compiler/tests-re/dune: -------------------------------------------------------------------------------- 1 | (env 2 | (_ 3 | (flags 4 | (:standard -w -32-69)))) 5 | 6 | (executables 7 | (names test_str) 8 | (libraries str re) 9 | (modes js)) 10 | 11 | (rule 12 | (alias runtest) 13 | (deps test_str.bc.js) 14 | (action 15 | (run node ./test_str.bc.js))) 16 | -------------------------------------------------------------------------------- /lib/tests/dune: -------------------------------------------------------------------------------- 1 | (include dune.inc) 2 | 3 | (rule 4 | (deps 5 | (glob_files *.ml)) 6 | (action 7 | (with-stdout-to 8 | dune.inc.gen 9 | (run gen-rules/gen.exe jsoo_lib_expect_tests)))) 10 | 11 | (rule 12 | (alias runtest) 13 | (action 14 | (diff dune.inc dune.inc.gen))) 15 | -------------------------------------------------------------------------------- /toplevel/bin/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names jsoo_mkcmis jsoo_mktop jsoo_listunits) 3 | (public_names jsoo_mkcmis jsoo_mktop jsoo_listunits) 4 | (package js_of_ocaml-toplevel) 5 | (libraries 6 | js_of_ocaml-compiler 7 | js_of_ocaml-compiler.findlib-support 8 | js_of_ocaml-compiler.runtime-files)) 9 | -------------------------------------------------------------------------------- /compiler/tests-compiler/dune: -------------------------------------------------------------------------------- 1 | (include dune.inc) 2 | 3 | (rule 4 | (deps 5 | (glob_files *.ml)) 6 | (action 7 | (with-stdout-to 8 | dune.inc.gen 9 | (run gen-rules/gen.exe jsoo_compiler_test)))) 10 | 11 | (rule 12 | (alias runtest) 13 | (action 14 | (diff dune.inc dune.inc.gen))) 15 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/flush_stubs.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "caml/mlvalues.h" 4 | #include "caml/memory.h" 5 | 6 | CAMLprim value flush_stdout_stderr (value unit) { 7 | CAMLparam0 (); /* v is ignored */ 8 | fflush(stderr); 9 | fflush(stdout); 10 | CAMLreturn (Val_unit); 11 | } 12 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-format/pr6824.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | include testing 3 | *) 4 | 5 | let f = Format.sprintf "[%i]";; 6 | print_endline (f 1);; 7 | print_endline (f 2);; 8 | 9 | let f = Format.asprintf "[%i]";; 10 | print_endline (f 1);; 11 | print_endline (f 2);; 12 | 13 | include Testing 14 | -------------------------------------------------------------------------------- /benchmarks/report-time-optim.config: -------------------------------------------------------------------------------- 1 | histogramref times node js_of_ocaml #31818f default 2 | histogram times node o3 #5db49c --opt=3 3 | histogram times node jsstring #bbe098 use-js-string 4 | histogram times node unsafe/js_of_ocaml #cb9d2c unsafe 5 | histogram times node nooptcall #de311d No call optimisation 6 | -------------------------------------------------------------------------------- /benchmarks/run.config: -------------------------------------------------------------------------------- 1 | # 2 | #interpreter v8 / node: apt-get install nodejs 3 | interpreter node /usr/bin/env node 4 | # 5 | #SpiderMonkey: apt-get install libmozjs-91-dev 6 | interpreter sm /usr/bin/env js91 -f 7 | # 8 | # JSC: apt-get install libjavascriptcoregtk-4.0-bin 9 | interpreter nitro /usr/bin/env jsc 10 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Example projects 2 | 3 | Build all projects: 4 | ``` 5 | $> dune build @examples/default 6 | ``` 7 | 8 | Or a single one: 9 | ``` 10 | $> dune build @examples//default 11 | ``` 12 | 13 | Compilation artifacts can be found in `${REPO_ROOT}/_build/default/examples/`. 14 | -------------------------------------------------------------------------------- /compiler/lib-dynlink/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name js_of_ocaml_compiler_dynlink) 3 | (public_name js_of_ocaml-compiler.dynlink) 4 | (synopsis "Js_of_ocaml compiler dynlink support") 5 | (library_flags (-linkall)) 6 | (libraries 7 | js_of_ocaml-compiler 8 | js_of_ocaml-compiler.runtime 9 | compiler-libs.bytecomp)) 10 | -------------------------------------------------------------------------------- /ppx/ppx_deriving_json/lib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ppx_deriving_json) 3 | (public_name js_of_ocaml-ppx_deriving_json) 4 | (synopsis "[@@deriving json]") 5 | (libraries compiler-libs.common ppxlib) 6 | (ppx_runtime_libraries js_of_ocaml.deriving) 7 | (kind ppx_deriver) 8 | (preprocess 9 | (pps ppxlib.metaquot))) 10 | -------------------------------------------------------------------------------- /toplevel/lib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name js_of_ocaml_toplevel) 3 | (public_name js_of_ocaml-toplevel) 4 | (synopsis "Js_of_ocaml toplevel library") 5 | (libraries 6 | js_of_ocaml-compiler 7 | js_of_ocaml-compiler.dynlink 8 | compiler-libs.bytecomp 9 | compiler-libs.toplevel) 10 | (preprocess 11 | (pps ppx_optcomp_light))) 12 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error3.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | match Array.to_list Sys.argv with 3 | | _ :: "unregister" :: _ -> 4 | let null = Array.unsafe_get [| 1 |] 1 in 5 | Callback.register "Printexc.handle_uncaught_exception" null 6 | | _ -> () 7 | 8 | let null : _ -> _ -> _ = Array.unsafe_get [||] 0 9 | 10 | let _ = null 1 2 11 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/effects.reference: -------------------------------------------------------------------------------- 1 | 5 2 | 42 3 | 42 4 | >> 42 0 5 | [t1] Sending 0 6 | [t2] Sending 1 7 | [t2] received 0 8 | [t1] received 1 9 | Hello, world! Coucou! Hello, world! 10 | Discontinued 11 | Unhandled 12 | Saw unhandled exception 13 | One-shot 14 | OCaml 15 | Send 42 16 | Recv: 42 17 | Send 43 18 | Recv: 43 19 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/lib-effects/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsoo_testsuite_effect) 3 | (enabled_if 4 | (and 5 | (>= %{ocaml_version} 5) 6 | (= %{profile} using-effects))) 7 | (inline_tests 8 | ;; This requires the unreleased dune 3.7 to work 9 | (enabled_if true) 10 | (modes js best)) 11 | (preprocess 12 | (pps ppx_expect))) 13 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bigarray/pr5115.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | (* PR#5115 - multiple evaluation of bigarray expr *) 5 | 6 | open Bigarray 7 | 8 | let f y0 = 9 | Printf.printf "***EXEC***\n%!"; 10 | y0 11 | 12 | let _ = 13 | let y = Array1.of_array float64 fortran_layout [| 1. |] in 14 | ignore ((f y).{1}); 15 | (f y).{1} <- 3.14 16 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test1.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | 9 | let () = 10 | Printf.printf "%d\n%!" @@ 11 | try_with (fun x -> x) 10 12 | { effc = (fun (type a) (e : a t) -> 13 | match e with 14 | | E -> Some (fun k -> 11) 15 | | e -> None) } 16 | -------------------------------------------------------------------------------- /ppx/ppx_js/as-lib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ppx_js) 3 | (public_name js_of_ocaml-ppx.as-lib) 4 | (synopsis "Js_of_ocaml ppx") 5 | (libraries compiler-libs.common ppxlib) 6 | (preprocess 7 | (pps ppxlib.metaquot))) 8 | 9 | (rule 10 | (targets ppx_js_internal.ml) 11 | (action 12 | (copy %{dep:../lib_internal/ppx_js_internal.ml} %{targets}))) 13 | -------------------------------------------------------------------------------- /examples/wysiwyg/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names main) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (rule 9 | (targets main.js) 10 | (action 11 | (run %{bin:js_of_ocaml} --source-map %{dep:main.bc} -o %{targets} --pretty))) 12 | 13 | (alias 14 | (name default) 15 | (deps main.js index.html)) 16 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-floatarray/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names floatarray) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target floatarray.referencejs) 8 | (deps floatarray.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./floatarray.bc.js)))) 13 | 14 | (alias 15 | (name runtest) 16 | (deps floatarray.referencejs)) 17 | -------------------------------------------------------------------------------- /tools/format-js.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "# Removing tabs" 4 | find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*\.js" -exec sed -i 's/ //g' {} \; 5 | 6 | echo "# Indent files" 7 | SCRIPT=$(readlink -f $0) 8 | SCRIPTPATH=`dirname $SCRIPT` 9 | find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*\.js" -exec emacs -batch {} -l ${SCRIPTPATH}/emacs-format-js.el -f emacs-format-js \; 10 | -------------------------------------------------------------------------------- /compiler/lib-runtime-files/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name js_of_ocaml_compiler_runtime_files) 3 | (libraries js_of_ocaml-compiler) 4 | (public_name js_of_ocaml-compiler.runtime-files)) 5 | 6 | (rule 7 | (target files.ml) 8 | (deps 9 | gen/gen.exe 10 | (glob_files ../../runtime/*.js)) 11 | (action 12 | (with-stdout-to 13 | %{target} 14 | (run %{deps})))) 15 | -------------------------------------------------------------------------------- /examples/graphics/main.ml: -------------------------------------------------------------------------------- 1 | open Js_of_ocaml 2 | open Graphics_js 3 | 4 | let init canvas = 5 | print_endline "initializing"; 6 | let () = open_canvas canvas in 7 | let () = 8 | Graphics_js.loop [ Graphics_js.Button_down ] (fun s -> 9 | Graphics_js.draw_rect (s.mouse_x - 5) (s.mouse_y - 5) 10 10) 10 | in 11 | () 12 | 13 | let () = Js.export "init" init 14 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/colorize.mli: -------------------------------------------------------------------------------- 1 | open Js_of_ocaml 2 | open Js_of_ocaml_tyxml 3 | 4 | val text : a_class:string -> string -> [> Html_types.div_content ] Tyxml_js.Html.elt 5 | 6 | val ocaml : a_class:string -> string -> [> Html_types.div_content ] Tyxml_js.Html.elt 7 | 8 | val highlight : 9 | [ `Pos of int ] -> [ `Last | `Pos of int ] -> Dom_html.element Js.t -> unit 10 | -------------------------------------------------------------------------------- /compiler/tests-sourcemap/dump.reference: -------------------------------------------------------------------------------- 1 | sourcemap for test.bc.js 2 | b.ml:1:4 -> 12: function <>f(x){return x - 1 | 0;} 3 | b.ml:1:6 -> 14: function f(<>x){return x - 1 | 0;} 4 | b.ml:1:10 -> 17: function f(x){<>return x - 1 | 0;} 5 | b.ml:1:6 -> 24: function f(x){return <>x - 1 | 0;} 6 | b.ml:1:15 -> 34: function f(x){return x - 1 | 0;<>} 7 | b.ml:1:4 -> 23: var Testlib_B = [0, <>f]; 8 | -------------------------------------------------------------------------------- /examples/cubes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Cubes 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/hyperbolic/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "fr": 3 | {"info": "Informations", 4 | "recenter": "Recentrer", 5 | "close": "Cliquez n'importe où pour retourner à l'arbre", 6 | "wikimediaCommons": "Voir la description de l'image sur Wikimedia Commons", 7 | "language": "En français", 8 | "noRef": "Aucune référence disponible.", 9 | "languages": "Langues", 10 | "ok": "OK" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/wiki/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names main) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (ocamllex wikicreole) 9 | 10 | (rule 11 | (targets main.js) 12 | (action 13 | (run %{bin:js_of_ocaml} --source-map %{dep:main.bc} -o %{targets} --pretty))) 14 | 15 | (alias 16 | (name default) 17 | (deps main.js index.html)) 18 | -------------------------------------------------------------------------------- /ppx/ppx_js/tests/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names main) 3 | (libraries toplevel_expect_test js_of_ocaml-ppx stdlib) 4 | (modes byte) 5 | (link_flags (-linkall))) 6 | 7 | (rule 8 | (targets ppx.mlt.corrected) 9 | (action 10 | (run %{exe:main.bc} %{dep:ppx.mlt}))) 11 | 12 | (rule 13 | (alias runtest) 14 | (package js_of_ocaml-ppx) 15 | (action 16 | (diff ppx.mlt ppx.mlt.corrected))) 17 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-digest/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names md5) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target md5.referencejs) 8 | (deps md5.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./md5.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps md5.reference md5.referencejs) 17 | (action 18 | (diff md5.reference md5.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-str/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names t01) 3 | (libraries str) 4 | (modes js)) 5 | 6 | (rule 7 | (target t01.referencejs) 8 | (deps t01.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./t01.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps t01.reference t01.referencejs) 17 | (action 18 | (diff t01.reference t01.referencejs))) 19 | -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- 1 | break-cases=fit-or-vertical 2 | break-fun-decl=fit-or-vertical 3 | break-infix=fit-or-vertical 4 | if-then-else=keyword-first 5 | parens-tuple=multi-line-only 6 | type-decl=sparse 7 | wrap-fun-args=false 8 | break-infix-before-func 9 | break-separators=before 10 | dock-collection-brackets=false 11 | margin=90 12 | module-item-spacing=sparse 13 | version=0.25.1 14 | ocaml-version=4.08.0 15 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bool/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-float/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-fun/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-int/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-list/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-queue/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-seq/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-stack/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-uchar/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-buffer/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-option/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-result/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | -------------------------------------------------------------------------------- /examples/cubes/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names cubes) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (rule 9 | (targets cubes.js) 10 | (action 11 | (run 12 | %{bin:js_of_ocaml} 13 | --source-map 14 | %{dep:cubes.bc} 15 | -o 16 | %{targets} 17 | --pretty))) 18 | 19 | (alias 20 | (name default) 21 | (deps cubes.js index.html)) 22 | -------------------------------------------------------------------------------- /examples/graph_viewer/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Graph viewer 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-bswap/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names bswap) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target bswap.referencejs) 8 | (deps bswap.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./bswap.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps bswap.reference bswap.referencejs) 17 | (action 18 | (diff bswap.reference bswap.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-buffer/test.reference: -------------------------------------------------------------------------------- 1 | Standard Library: Module Buffer 2 | Buffer truncate: negative passed 3 | Buffer truncate: large passed 4 | Buffer truncate: in-range passed 5 | Buffer reset: non-zero passed 6 | Buffer reset: zero passed 7 | Buffer add_utf_8_uchar: test against spec passed 8 | Buffer add_utf_16be_uchar: test against spec passed 9 | Buffer add_utf_16le_uchar: test against spec passed 10 | -------------------------------------------------------------------------------- /examples/minesweeper/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names main) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (rule 9 | (targets main.js) 10 | (action 11 | (run %{bin:js_of_ocaml} --source-map %{dep:main.bc} -o %{targets} --pretty))) 12 | 13 | (alias 14 | (name default) 15 | (deps 16 | main.js 17 | index.html 18 | (glob_files sprites/*.{png,svg}))) 19 | -------------------------------------------------------------------------------- /examples/planet/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names planet) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (rule 9 | (targets planet.js) 10 | (action 11 | (run 12 | %{bin:js_of_ocaml} 13 | --source-map 14 | %{dep:planet.bc} 15 | -o 16 | %{targets} 17 | --pretty))) 18 | 19 | (alias 20 | (name default) 21 | (deps planet.js index.html texture.jpg)) 22 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error2.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | (* Make sure Printexc is linked *) 3 | let _ = Printexc.to_string Not_found in 4 | match Array.to_list Sys.argv with 5 | | _ :: "unregister" :: _ -> 6 | let null = Array.unsafe_get [| 1 |] 1 in 7 | Callback.register "Printexc.handle_uncaught_exception" null 8 | | _ -> () 9 | 10 | [@@@ocaml.warning "-8"] 11 | 12 | let _ = 13 | match 3 with 14 | | 2 -> () 15 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project has adopted the [OCaml Code of Conduct](https://github.com/ocaml/code-of-conduct/blob/main/CODE_OF_CONDUCT.md). 4 | 5 | # Enforcement 6 | 7 | This project follows the OCaml Code of Conduct [enforcement policy](https://github.com/ocaml/code-of-conduct/blob/main/CODE_OF_CONDUCT.md#enforcement). 8 | 9 | To report any violations, please contact 10 | -------------------------------------------------------------------------------- /compiler/tests-runtime-events/dune: -------------------------------------------------------------------------------- 1 | (env 2 | (_ 3 | (flags 4 | (:standard -w -32-69)))) 5 | 6 | (executables 7 | (names test_runtime_events) 8 | (enabled_if 9 | (>= %{ocaml_version} 5.1.0)) 10 | (libraries runtime_events) 11 | (modes js)) 12 | 13 | (rule 14 | (alias runtest) 15 | (deps test_runtime_events.bc.js) 16 | (enabled_if 17 | (>= %{ocaml_version} 5.1.0)) 18 | (action 19 | (run node ./test_runtime_events.bc.js))) 20 | -------------------------------------------------------------------------------- /ppx/ppx_deriving_json/tests/main.ml: -------------------------------------------------------------------------------- 1 | let mapper _args = 2 | (*this mapper can only be used the way it is defined here, i.e. 3 | no other fields can be updated.*) 4 | let structure _ st = 5 | Ppxlib_ast.Selected_ast.of_ocaml Structure st 6 | |> Ppxlib.Driver.map_structure 7 | |> Ppxlib.Selected_ast.to_ocaml Structure 8 | in 9 | { Ast_mapper.default_mapper with structure } 10 | 11 | let () = Toplevel_expect_test.run mapper 12 | -------------------------------------------------------------------------------- /toplevel/test/test_toplevel.reference: -------------------------------------------------------------------------------- 1 | 2 | external parseInt : float -> int = "parseInt" 3 | let f = 3.14 4 | let () = Printf.printf "parseInt(%f) = %d\n" f (parseInt f);; 5 | Dynlink: looking for symbol parseInt 6 | parseInt(3.140000) = 3 7 | external parseInt : float -> int = "parseInt" 8 | val f : float = 3.14 9 | 10 | let () = print_endline "hello";; 11 | hello 12 | 1+;; 13 | : Line 3, characters 2-4: 14 | : Error: Syntax error 15 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-random/defaultinit.reference: -------------------------------------------------------------------------------- 1 | 754 262 510 865 996 861 495 37 283 434 98 495 144 34 806 28 180 58 416 138 654 2 | 3 | 889.820262688 163.886958714 809.261276959 163.701988701 285.093960955 159.853482937 753.952858458 718.309149819 113.116488344 275.531702635 844.229063886 592.96154003 974.771041906 295.713668995 374.084883719 600.675753364 478.414704679 821.538029441 193.559890207 858.508699222 795.477498048 4 | All tests succeeded. 5 | -------------------------------------------------------------------------------- /tools/toplevel_expect/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name toplevel_expect_test) 3 | (libraries compiler-libs.common compiler-libs.toplevel)) 4 | 5 | (rule 6 | (targets toplevel_expect_test.ml) 7 | (deps 8 | ../select/select.exe 9 | toplevel_expect_test.ml-4.08 10 | toplevel_expect_test.ml-4.09 11 | toplevel_expect_test.ml-4.10 12 | toplevel_expect_test.ml-default) 13 | (action 14 | (with-stdout-to 15 | %{targets} 16 | (run %{deps})))) 17 | -------------------------------------------------------------------------------- /.github/workflows/changelog.yml: -------------------------------------------------------------------------------- 1 | name: Check changelog 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | types: 8 | - labeled 9 | - opened 10 | - reopened 11 | - synchronize 12 | - unlabeled 13 | 14 | jobs: 15 | check-changelog: 16 | name: Check changelog 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Check changelog 20 | uses: tarides/changelog-check-action@v1 21 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsoo_testsuite) 3 | (libraries unix compiler-libs.common) 4 | (foreign_stubs 5 | (language c) 6 | (names bigarray_stubs flush_stubs)) 7 | (js_of_ocaml 8 | (javascript_files runtime.js)) 9 | (inline_tests 10 | (modes js best)) 11 | (preprocess 12 | (pps ppx_expect))) 13 | 14 | (ocamlyacc calc_parser) 15 | 16 | (ocamllex calc_lexer) 17 | 18 | (ocamlyacc parser_1307) 19 | 20 | (ocamllex lexer_1307) 21 | -------------------------------------------------------------------------------- /tools/version/dune: -------------------------------------------------------------------------------- 1 | (* -*- tuareg -*- *) 2 | open StdLabels 3 | open Jbuild_plugin.V1 4 | 5 | let git_version = 6 | match run_and_read_lines "git describe --always --dirty" with 7 | | exception _ -> "" 8 | | version :: _ -> version 9 | | [] -> "" 10 | 11 | let dyn = 12 | Printf.sprintf 13 | {| 14 | (rule 15 | (target GIT-VERSION) 16 | (action (with-stdout-to %%{target} (echo "%s")))) 17 | |} 18 | git_version 19 | 20 | let () = send dyn 21 | -------------------------------------------------------------------------------- /examples/webgl/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names webgldemo) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (rule 9 | (targets webgldemo.js) 10 | (action 11 | (run 12 | %{bin:js_of_ocaml} 13 | --source-map 14 | %{dep:webgldemo.bc} 15 | -o 16 | %{targets} 17 | --pretty 18 | --file 19 | %{dep:monkey.model}))) 20 | 21 | (alias 22 | (name default) 23 | (deps webgldemo.js index.html)) 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is and how to reproduce it. 12 | 13 | **Expected behavior** 14 | A clear and concise description of what you expected to happen. 15 | 16 | **Versions** 17 | Version of packages used to reproduce the bug 18 | (ocamlc, js_of_ocaml, ..) 19 | -------------------------------------------------------------------------------- /benchmarks/report-size-optim.config: -------------------------------------------------------------------------------- 1 | #histogram sizes "" unsafe/js_of_ocaml #fb9f3f Unsafe 2 | histogramref sizes "" js_of_ocaml/generated #00876c Default 3 | histogram sizes "" o3 #62a36d --opt=3 4 | histogram sizes "" jsstring #a4bd75 use js string 5 | histogram sizes "" nooptcall #e6d589 no optimization of calls 6 | histogram sizes "" noinline #e5a760 no inlining 7 | histogram sizes "" notcompact #e2764e no compact code 8 | histogram sizes "" nodeadcode #d43d51 no dead code removal -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error1.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | match Array.to_list Sys.argv with 3 | | _ :: "unregister" :: _ -> 4 | let null = Array.unsafe_get [| 1 |] 1 in 5 | Callback.register "Printexc.handle_uncaught_exception" null 6 | | _ -> () 7 | 8 | exception D of int * string * Int64.t 9 | 10 | let _ = 11 | Printexc.register_printer (function 12 | | D _ -> Some "custom printer" 13 | | _ -> None) 14 | 15 | let _ = raise (D (2, "test", 43L)) 16 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-filename/extension.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | let () = 5 | let test f e = 6 | assert(Filename.extension f = e); 7 | assert(Filename.extension ("foo/" ^ f) = e); 8 | assert(f = Filename.remove_extension f ^ Filename.extension f) 9 | in 10 | test "" ""; 11 | test "foo" ""; 12 | test "foo.txt" ".txt"; 13 | test "foo.txt.gz" ".gz"; 14 | test ".foo" ""; 15 | test "." ""; 16 | test ".." ""; 17 | test "foo..txt" ".txt" 18 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-random/defaultinit.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | include testing 3 | *) 4 | 5 | (* Check that the numbers drawn from the default state are the same 6 | on all platforms. *) 7 | 8 | open Random 9 | 10 | let _ = 11 | for i = 0 to 20 do 12 | print_char ' '; print_int (int 1000); 13 | done; 14 | print_newline (); print_newline (); 15 | for i = 0 to 20 do 16 | print_char ' '; print_float (float 1000.); 17 | done 18 | 19 | let _ = exit 0 20 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bytes-utf/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test) 3 | (libraries) 4 | (flags 5 | (:standard \ -strict-sequence)) 6 | (modes 7 | js 8 | (best exe))) 9 | 10 | (rule 11 | (target test.referencejs) 12 | (deps test.bc.js) 13 | (action 14 | (with-stdout-to 15 | %{target} 16 | (run node ./test.bc.js)))) 17 | 18 | (rule 19 | (alias runtest) 20 | (deps test.reference test.referencejs) 21 | (action 22 | (diff test.reference test.referencejs))) 23 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/ocp_indent.ok.ml: -------------------------------------------------------------------------------- 1 | let _ = Approx_lexer.enable_extension "lwt" 2 | 3 | let indent s in_lines = 4 | let output = 5 | { IndentPrinter.debug = false 6 | ; config = IndentConfig.default 7 | ; in_lines 8 | ; indent_empty = true 9 | ; adaptive = true 10 | ; kind = IndentPrinter.Print (fun s acc -> acc ^ s) 11 | } 12 | in 13 | let stream = Nstream.of_string s in 14 | IndentPrinter.proceed output stream IndentBlock.empty "" 15 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-random/selfinit.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | (* Test that two Random.self_init() in close succession will not result 5 | in the same PRNG state. 6 | Note that even when the code is correct this test is expected to fail 7 | once in 2^30 runs. 8 | *) 9 | 10 | let () = 11 | Random.self_init (); 12 | let x = Random.bits () in 13 | Random.self_init (); 14 | let y = Random.bits () in 15 | if x = y then print_endline "FAILED" else print_endline "PASSED" 16 | -------------------------------------------------------------------------------- /examples/wiki/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Realtime wiki syntax parsing 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /benchmarks/report-compiletime.config: -------------------------------------------------------------------------------- 1 | histogram compiletimes "" opt #3e9b99 ocamlopt 2 | histogram compiletimes "" byte #5db49c ocamlc 3 | histogramref compiletimes "" js_of_ocaml #88cb9a js_of_ocaml 4 | histogram compiletimes "" o3 #bbe098 --opt=3 5 | histogram compiletimes "" nooptcall #c0c15e no optimization of calls 6 | histogram compiletimes "" noinline #cb9d2c no inlining 7 | histogram compiletimes "" notcompact #d7710d no compact code 8 | histogram compiletimes "" nodeadcode #de311d no dead code removal 9 | -------------------------------------------------------------------------------- /examples/boulderdash/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Boulder Dash 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/minesweeper/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Minesweeper 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/wysiwyg/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Kakadu's WYSIWYG wiki editor 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /compiler/bin-jsoo_minify/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name jsoo_minify) 3 | (public_name jsoo_minify) 4 | (package js_of_ocaml-compiler) 5 | (libraries jsoo_cmdline js_of_ocaml-compiler cmdliner compiler-libs.common) 6 | (flags 7 | (:standard -safe-string))) 8 | 9 | (rule 10 | (targets jsoo_minify.1) 11 | (action 12 | (with-stdout-to 13 | %{targets} 14 | (run %{bin:jsoo_minify} --help=groff)))) 15 | 16 | (install 17 | (section man) 18 | (package js_of_ocaml-compiler) 19 | (files jsoo_minify.1)) 20 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-revapply/revapply.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply" 5 | 6 | let f x = x + x 7 | let g x = x * x 8 | let h x = x + 1 9 | let add x y = x + y 10 | 11 | let _ = 12 | List.iter (fun x -> 13 | print_int x; print_newline () 14 | ) 15 | [ 16 | 3 |> f; (* 6 *) 17 | 3 |> f |> g; (* 36 *) 18 | 3 |> g |> f; (* 18 *) 19 | 3 |> f |> g |> h; (* 37 *) 20 | 3 |> add 2 |> add 3 |> f |> g |> add 4; (* 260 *) 21 | ] 22 | -------------------------------------------------------------------------------- /tools/version/gen/gen.ml: -------------------------------------------------------------------------------- 1 | let version = Sys.argv.(1) 2 | 3 | let git_version = Sys.argv.(2) 4 | 5 | let version = 6 | let ic = open_in version in 7 | let version = try input_line ic with End_of_file -> "" in 8 | close_in ic; 9 | version 10 | 11 | let git_version = 12 | let ic = open_in git_version in 13 | let git_version = try input_line ic with End_of_file -> "" in 14 | close_in ic; 15 | git_version 16 | 17 | let () = Printf.printf {| 18 | let s = "%s" 19 | let git_version = "%s" 20 | |} version git_version 21 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/evenodd.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | 9 | let rec even n = 10 | if n = 0 then true 11 | else try_with odd (n-1) 12 | { effc = fun (type a) (e : a t) -> 13 | match e with 14 | | E -> Some (fun k -> assert false) 15 | | _ -> None } 16 | and odd n = 17 | if n = 0 then false 18 | else even (n-1) 19 | 20 | let _ = 21 | let n = 100_000 in 22 | Printf.printf "even %d is %B\n%!" n (even n) 23 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/basic-modules/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names recursive_module_init) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target recursive_module_init.referencejs) 8 | (deps recursive_module_init.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./recursive_module_init.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps recursive_module_init.reference recursive_module_init.referencejs) 17 | (action 18 | (diff recursive_module_init.reference recursive_module_init.referencejs))) 19 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test3.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | exception X 9 | 10 | let () = 11 | Printf.printf "%d\n%!" @@ 12 | match_with (fun () -> 13 | Printf.printf "in handler. raising X\n%!"; 14 | raise X) () 15 | { retc = (fun v -> v); 16 | exnc = (function 17 | | X -> 10 18 | | e -> raise e); 19 | effc = (fun (type a) (e : a t) -> 20 | match e with 21 | | E -> Some (fun k -> 11) 22 | | e -> None) } 23 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-random/testvectors.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | (* Check the numbers drawn from a known state against the numbers 5 | obtained from the reference Java implementation. *) 6 | 7 | open Bigarray 8 | 9 | let _ = 10 | let a = Array1.of_array Int64 C_layout [| 1L; 2L; 3L; 4L |] in 11 | (* Violate abstraction of type Random.State.t to manipulate state directly *) 12 | let r = (Obj.magic a : Random.State.t) in 13 | for i = 0 to 49 do 14 | Printf.printf "%Ld\n" (Random.State.bits64 r); 15 | done 16 | 17 | let _ = exit 0 18 | -------------------------------------------------------------------------------- /lib/lwt/graphics/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name graphics_js) 3 | (public_name js_of_ocaml-lwt.graphics) 4 | (synopsis "Graphics for js_of_ocaml.") 5 | (optional) 6 | (libraries js_of_ocaml js_of_ocaml-lwt lwt graphics) 7 | (foreign_stubs 8 | (language c) 9 | (names graphics_js_stubs)) 10 | (preprocess 11 | (pps js_of_ocaml-ppx))) 12 | 13 | (rule 14 | (targets graphics_js_stubs.c) 15 | (deps 16 | (glob_files *.ml)) 17 | (mode promote) 18 | (action 19 | (with-stdout-to 20 | %{targets} 21 | (run ../../gen_stubs/gen_stubs.exe %{deps})))) 22 | -------------------------------------------------------------------------------- /lib/runtime/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name jsoo_runtime) 3 | (foreign_stubs 4 | (language c) 5 | (names js_of_ocaml_runtime_stubs)) 6 | (public_name js_of_ocaml-compiler.runtime)) 7 | 8 | (rule 9 | (targets js_of_ocaml_runtime_stubs.c) 10 | (deps 11 | (glob_files *.ml)) 12 | (mode promote) 13 | (action 14 | (with-stdout-to 15 | %{targets} 16 | (run ../gen_stubs/gen_stubs.exe %{deps})))) 17 | 18 | (rule 19 | (targets runtime_version.ml) 20 | (deps 21 | (:input-file ../../version.ml.in)) 22 | (action 23 | (copy %{input-file} %{targets}))) 24 | -------------------------------------------------------------------------------- /runtime/dune: -------------------------------------------------------------------------------- 1 | (install 2 | (section lib) 3 | (package js_of_ocaml-compiler) 4 | (files 5 | bigarray.js 6 | bigstring.js 7 | dynlink.js 8 | fs.js 9 | fs_fake.js 10 | fs_node.js 11 | gc.js 12 | graphics.js 13 | ieee_754.js 14 | int64.js 15 | internalMod.js 16 | io.js 17 | jslib.js 18 | jslib_js_of_ocaml.js 19 | lexing.js 20 | marshal.js 21 | md5.js 22 | mlBytes.js 23 | nat.js 24 | parsing.js 25 | stdlib.js 26 | toplevel.js 27 | unix.js 28 | weak.js 29 | domain.js 30 | prng.js 31 | sync.js 32 | runtime_events.js)) 33 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error1.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Error 1 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error2.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Error 1 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error3.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Error 1 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-hashtbl/hfun.reference: -------------------------------------------------------------------------------- 1 | -- Strings: 2 | "" 00000000 3 | "Hello world" 364b8272 4 | -- Integers: 5 | 0 07be548a 6 | -1 3653e015 7 | 42 1792870b 8 | 2^30-1 23c392d0 9 | -2^30 0c66fde3 10 | -- Floats: 11 | +0.0 07be548a 12 | -0.0 07be548a 13 | +infty 23ea56fb 14 | -infty 059f7872 15 | NaN 00000000 16 | NaN#2 00000000 17 | NaN#3 00000000 18 | -- Native integers: 19 | 0 07be548a 20 | -1 3653e015 21 | 42 1792870b 22 | 2^30-1 23c392d0 23 | -2^30 0c66fde3 24 | -- Lists: 25 | [0..10] 0ade0fc9 26 | [0..12] 0ade0fc9 27 | [10..0] 0cd6259d 28 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/effects_flags.ml: -------------------------------------------------------------------------------- 1 | let enable b n = 2 | let f = if b then "--enable" else "--disable" in 3 | [ f; n ] 4 | 5 | let () = 6 | let major = String.split_on_char '.' Sys.ocaml_version |> List.hd |> int_of_string in 7 | let has_effect = major >= 5 in 8 | let l = enable has_effect "effects" in 9 | match Sys.argv |> Array.to_list |> List.tl with 10 | | "txt" :: [] -> List.iter print_endline l 11 | | "sexp" :: [] -> 12 | print_endline "("; 13 | List.iter print_endline l; 14 | print_endline ")" 15 | | _ -> assert false 16 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/calc_lexer.mll: -------------------------------------------------------------------------------- 1 | { 2 | open Calc_parser (* The type token is defined in calc_parser.mli *) 3 | exception Eof 4 | } 5 | 6 | rule token = parse 7 | [' ' '\t' '\r'] { token lexbuf } (* skip blanks *) 8 | | ['\n' ] { EOL } 9 | | ['0'-'9']+ as lxm { INT(int_of_string lxm) } 10 | | '+' { PLUS } 11 | | '-' { MINUS } 12 | | '*' { TIMES } 13 | | '/' { DIV } 14 | | '(' { LPAREN } 15 | | ')' { RPAREN } 16 | | eof { raise Eof } 17 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error1-unregister.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Error 1 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error2-unregister.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Error 1 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/bin/error3-unregister.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Error 1 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test4.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += Foo : int -> int t 8 | 9 | let r = 10 | try_with perform (Foo 3) 11 | { effc = fun (type a) (e : a t) -> 12 | match e with 13 | | Foo i -> Some (fun (k : (a,_) continuation) -> 14 | try_with (continue k) (i+1) 15 | { effc = fun (type a) (e : a t) -> 16 | match e with 17 | | Foo i -> Some (fun k -> failwith "NO") 18 | | e -> None }) 19 | | e -> None } 20 | 21 | let () = Printf.printf "%d\n" r 22 | -------------------------------------------------------------------------------- /examples/boulderdash/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names boulderdash) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (rule 9 | (targets boulderdash.js) 10 | (deps 11 | (glob_files maps/*.map)) 12 | (action 13 | (run 14 | %{bin:js_of_ocaml} 15 | --source-map 16 | %{dep:boulderdash.bc} 17 | -o 18 | %{targets} 19 | --pretty 20 | --file 21 | %{dep:maps.txt} 22 | --file 23 | maps))) 24 | 25 | (alias 26 | (name default) 27 | (deps 28 | boulderdash.js 29 | index.html 30 | (glob_files sprites/*.{png,svg}))) 31 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/used_cont.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | 9 | let r = ref None 10 | let () = 11 | match_with (fun _ -> perform E; 42) () 12 | { retc = (fun n -> assert (n = 42)); 13 | exnc = (fun e -> raise e); 14 | effc = fun (type a) (e : a t) -> 15 | match e with 16 | | E -> Some (fun (k : (a,_) continuation) -> 17 | continue k (); 18 | r := Some (k : (unit, unit) continuation); 19 | Gc.full_major (); 20 | print_string "ok\n") 21 | | _ -> None } 22 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test11.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | (* Tests RESUMETERM with extra_args != 0 in bytecode, 5 | by calling a handler with a tail-continue that returns a function *) 6 | 7 | open Effect 8 | open Effect.Deep 9 | 10 | type _ t += E : int t 11 | 12 | let handle comp = 13 | try_with comp () 14 | { effc = fun (type a) (e : a t) -> 15 | match e with 16 | | E -> Some (fun (k : (a,_) continuation) -> continue k 10) 17 | | _ -> None } 18 | 19 | let () = 20 | handle (fun () -> 21 | Printf.printf "%d\n" (perform E); 22 | Printf.printf "%d\n") 42 23 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/basic-modules/recursive_module_init.reference: -------------------------------------------------------------------------------- 1 | f1[real]: nonrec => 42, self => 42, mod => __ 2 | f2[real]: nonrec => 42, self => 42, mod => __ 3 | f3[stub]: nonrec => __, self => __, mod => __ 4 | f4[real]: nonrec => 42, self => 42, mod => __ 5 | f5[stub]: nonrec => __, self => __, mod => __ 6 | M.f1[real]: nonrec => 42, self => 42, mod => 42 7 | M.f2[real]: nonrec => 42, self => 42, mod => 42 8 | M.f3[stub]: nonrec => 42, self => 42, mod => 42 9 | M.f4[real]: nonrec => 42, self => 42, mod => 42 10 | M.f5[real]: nonrec => 42, self => 42, mod => 42 11 | go 12 | go 13 | go 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea 4 | title: "[FEATURE REQUEST]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-bswap/bswap.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Printf 5 | 6 | external bswap16: int -> int = "%bswap16" 7 | external bswap32: int32 -> int32 = "%bswap_int32" 8 | external bswap64: int64 -> int64 = "%bswap_int64" 9 | 10 | let d16 = [0x11223344; 11 | 0x0000f0f0] 12 | let d32 = [0x11223344l; 13 | 0xf0f0f0f0l] 14 | let d64 = [0x1122334455667788L; 15 | 0xf0f0f0f0f0f0f0f0L] 16 | 17 | let _ = 18 | List.iter (fun x -> printf "%x\n" (bswap16 x)) d16; 19 | List.iter (fun x -> printf "%lx\n" (bswap32 x)) d32; 20 | List.iter (fun x -> printf "%Lx\n" (bswap64 x)) d64 21 | -------------------------------------------------------------------------------- /lib/lwt/graphics/graphics_js_stubs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void caml_gr_doc_of_state () { 4 | fprintf(stderr, "Unimplemented Javascript primitive caml_gr_doc_of_state!\n"); 5 | exit(1); 6 | } 7 | void caml_gr_state_create () { 8 | fprintf(stderr, "Unimplemented Javascript primitive caml_gr_state_create!\n"); 9 | exit(1); 10 | } 11 | void caml_gr_state_get () { 12 | fprintf(stderr, "Unimplemented Javascript primitive caml_gr_state_get!\n"); 13 | exit(1); 14 | } 15 | void caml_gr_state_set () { 16 | fprintf(stderr, "Unimplemented Javascript primitive caml_gr_state_set!\n"); 17 | exit(1); 18 | } 19 | -------------------------------------------------------------------------------- /examples/hyperbolic/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names hypertree) 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (preprocess 6 | (pps js_of_ocaml-ppx))) 7 | 8 | (rule 9 | (targets hypertree.js) 10 | (action 11 | (run 12 | %{bin:js_of_ocaml} 13 | --source-map 14 | %{dep:hypertree.bc} 15 | -o 16 | %{targets} 17 | --pretty 18 | --file 19 | %{dep:image_info.json} 20 | --file 21 | %{dep:messages.json} 22 | --file 23 | %{dep:tree.json}))) 24 | 25 | (alias 26 | (name default) 27 | (deps 28 | hypertree.js 29 | index.html 30 | (glob_files icons/*.{png,jpg}) 31 | (glob_files thumbnails/*.{png,jpg}))) 32 | -------------------------------------------------------------------------------- /toplevel/examples/eval/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names eval) 3 | (libraries js_of_ocaml-compiler js_of_ocaml-toplevel) 4 | (link_flags 5 | (:standard -linkall)) 6 | (modes byte) 7 | (preprocess 8 | (pps js_of_ocaml-ppx))) 9 | 10 | (rule 11 | (targets export.txt) 12 | (deps eval.bc) 13 | (action 14 | (run jsoo_listunits -o %{targets} stdlib))) 15 | 16 | (rule 17 | (targets eval.js) 18 | (action 19 | (run 20 | %{bin:js_of_ocaml} 21 | --export 22 | %{dep:export.txt} 23 | --toplevel 24 | --pretty 25 | %{dep:eval.bc} 26 | -o 27 | %{targets}))) 28 | 29 | (alias 30 | (name default) 31 | (deps eval.js index.html)) 32 | -------------------------------------------------------------------------------- /compiler/tests-num/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (libraries num) 4 | (modes 5 | js 6 | (best exe)) 7 | (flags 8 | (:standard -linkall -w -3-7-33-35-37 -safe-string -no-strict-sequence))) 9 | 10 | (rule 11 | (target main.referencejs) 12 | (deps main.bc.js) 13 | (action 14 | (with-stdout-to 15 | %{target} 16 | (run node ./main.bc.js)))) 17 | 18 | (rule 19 | (target main.reference) 20 | (deps main.exe) 21 | (action 22 | (with-stdout-to 23 | %{target} 24 | (run ./main.exe)))) 25 | 26 | (rule 27 | (alias runtest) 28 | (deps main.reference main.referencejs) 29 | (action 30 | (diff main.reference main.referencejs))) 31 | -------------------------------------------------------------------------------- /examples/planet/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Planet 7 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /compiler/tests-toplevel/test_toplevel.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | let content = {| 3 | let () = print_endline "hello";; 4 | 1+;; 5 | Missing_module.f;; 6 | |} in 7 | Topdirs.dir_directory "/static/cmis"; 8 | Toploop.initialize_toplevel_env (); 9 | Toploop.input_name := "//toplevel//"; 10 | let lexbuf = Lexing.from_string content in 11 | while true do 12 | try 13 | let phr = !Toploop.parse_toplevel_phrase lexbuf in 14 | if not (Toploop.execute_phrase true Format.std_formatter phr) then raise Exit 15 | with 16 | | End_of_file -> 17 | flush_all (); 18 | exit 0 19 | | x -> Location.report_exception Format.std_formatter x 20 | done 21 | -------------------------------------------------------------------------------- /compiler/tests-full/dune: -------------------------------------------------------------------------------- 1 | (rule 2 | (targets stdlib.cma.js) 3 | (mode 4 | (promote (until-clean))) 5 | (enabled_if 6 | (= %{ocaml_version} "5.0.0")) 7 | (action 8 | (run 9 | %{bin:js_of_ocaml} 10 | --pretty 11 | --debuginfo 12 | %{lib:stdlib:stdlib.cma} 13 | -o 14 | %{targets}))) 15 | 16 | (rule 17 | (targets stdlib.cma.output.js) 18 | (enabled_if 19 | (= %{ocaml_version} "5.0.0")) 20 | (action 21 | (with-stdout-to 22 | %{targets} 23 | (run tail -n +3 %{dep:stdlib.cma.js})))) 24 | 25 | (rule 26 | (alias runtest) 27 | (enabled_if 28 | (= %{ocaml_version} "5.0.0")) 29 | (action 30 | (diff stdlib.cma.expected.js stdlib.cma.output.js))) 31 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test5.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += Foo : int -> int t 8 | 9 | let f () = (perform (Foo 3)) (* 3 + 1 *) 10 | + (perform (Foo 3)) (* 3 + 1 *) 11 | 12 | let r = 13 | try_with f () 14 | { effc = fun (type a) (e : a t) -> 15 | match e with 16 | | Foo i -> Some (fun (k : (a, _) continuation) -> 17 | try_with (continue k) (i + 1) 18 | { effc = fun (type a) (e : a t) -> 19 | match e with 20 | | Foo i -> Some (fun k -> failwith "NO") 21 | | _ -> None }) 22 | | e -> None } 23 | 24 | let () = Printf.printf "%d\n" r 25 | -------------------------------------------------------------------------------- /dune-workspace.dev: -------------------------------------------------------------------------------- 1 | (lang dune 3.7) 2 | 3 | ;; Install the following opam switches, copy this file as 4 | ;; dune-workspace and run: 5 | ;; 6 | ;; $ dune build @install 7 | ;; 8 | ;; This will build js_of_ocaml against all these version of OCaml 9 | 10 | (context 11 | (opam 12 | (switch 4.08.1))) 13 | 14 | (context 15 | (opam 16 | (switch 4.09.1))) 17 | 18 | (context 19 | (opam 20 | (switch 4.10.2))) 21 | 22 | (context 23 | (opam 24 | (switch 4.11.2))) 25 | 26 | (context 27 | (opam 28 | (switch 4.12.1))) 29 | 30 | (context 31 | (opam 32 | (switch 4.13.1))) 33 | 34 | (context 35 | (opam 36 | (switch 4.14.0))) 37 | 38 | (context 39 | (opam 40 | (switch 5.0.0))) 41 | -------------------------------------------------------------------------------- /HACKING.md: -------------------------------------------------------------------------------- 1 | # Release procedure 2 | * update VERSION 3 | * Documentation 4 | * Make sure the doc is up to date (See Documentation generation) 5 | * In the wikidoc branch, copy dev to VERSION 6 | * dune-release tag $(cat VERSION) 7 | * dune-release distrib 8 | * DUNE_RELEASE_DELEGATE=github-dune-release-delegate dune-release publish distrib 9 | * dune-release opam pkg 10 | * dune-release opam submit 11 | 12 | # Documentation generation 13 | * make doc 14 | * make installdoc 15 | * cd _wikidoc 16 | * git diff # review diff 17 | * git commit -am "sync doc" 18 | * git push origin wikidoc 19 | 20 | # Ignore reformating commit in git blame 21 | * git config blame.ignoreRevsFile .git-blame-ignore-revs -------------------------------------------------------------------------------- /compiler/tests-compiler/es6.ml: -------------------------------------------------------------------------------- 1 | let%expect_test _ = 2 | let prog = 3 | {| 4 | let f x = 5 | let g y = 6 | let h z = x + y + z in 7 | h 7 8 | in 9 | g 10 | |} 11 | in 12 | let flags = [ "--enable"; "es6" ] in 13 | let program = Util.compile_and_parse ~effects:false ~flags prog in 14 | Util.print_program program; 15 | [%expect 16 | {| 17 | (globalThis=>{ 18 | "use strict"; 19 | var 20 | runtime = globalThis.jsoo_runtime, 21 | f = x=>{var g = y=>(x + y | 0) + 7 | 0; return g;}, 22 | Test = [0, f]; 23 | runtime.caml_register_global(0, Test, "Test"); 24 | return;}) 25 | (globalThis); 26 | //end |}] 27 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bytes/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test_bytes binary) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test_bytes.referencejs) 8 | (deps test_bytes.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test_bytes.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test_bytes.reference test_bytes.referencejs) 17 | (action 18 | (diff test_bytes.reference test_bytes.referencejs))) 19 | 20 | (rule 21 | (target binary.referencejs) 22 | (deps binary.bc.js) 23 | (action 24 | (with-stdout-to 25 | %{target} 26 | (run node ./binary.bc.js)))) 27 | 28 | (alias 29 | (name runtest) 30 | (deps binary.referencejs)) 31 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-printf/pr6534.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | include testing 3 | *) 4 | 5 | (* these are not valid under -strict-formats, but we test them here 6 | for backward-compatibility *) 7 | open Printf 8 | 9 | let () = 10 | printf "1 [%.5s]\n" "foo"; 11 | printf "2 [%.*s]\n" 5 "foo"; 12 | printf "3 [%.-5s]\n" "foo"; 13 | printf "4 [%-.5s]\n" "foo"; 14 | printf "5 [%-.*s]\n" 5 "foo"; 15 | printf "6 [%.*s]\n" (-5) "foo"; 16 | 17 | printf "1 [%.7S]\n" "foo"; 18 | printf "2 [%.*S]\n" 7 "foo"; 19 | printf "3 [%.-7S]\n" "foo"; 20 | printf "4 [%-.7S]\n" "foo"; 21 | printf "5 [%-.*S]\n" 7 "foo"; 22 | printf "6 [%.*S]\n" (-7) "foo"; 23 | () 24 | 25 | include Testing 26 | -------------------------------------------------------------------------------- /examples/separate_compilation/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Separate compilation 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /compiler/tests-toplevel/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test_toplevel) 3 | (libraries js_of_ocaml-compiler.dynlink compiler-libs.toplevel) 4 | (flags 5 | (:standard -linkall)) 6 | (modes byte)) 7 | 8 | (rule 9 | (targets test_toplevel.js) 10 | (action 11 | (run %{bin:js_of_ocaml} --toplevel %{dep:test_toplevel.bc} -o %{targets}))) 12 | 13 | (rule 14 | (target test_toplevel.referencejs) 15 | (deps test_toplevel.js) 16 | (action 17 | (with-stdout-to 18 | %{target} 19 | (run node ./test_toplevel.js)))) 20 | 21 | (rule 22 | (alias runtest) 23 | (deps test_toplevel.reference test_toplevel.referencejs) 24 | (action 25 | (diff test_toplevel.reference test_toplevel.referencejs))) 26 | -------------------------------------------------------------------------------- /dune: -------------------------------------------------------------------------------- 1 | (env 2 | (dev 3 | (flags 4 | (:standard -w +a-4-40-41-42-44-48-58-66-70))) 5 | (using-effects 6 | (js_of_ocaml 7 | (compilation_mode separate) 8 | (flags 9 | (:standard --enable effects)) 10 | (build_runtime_flags 11 | (:standard --enable effects)))) 12 | (bench_no_debug 13 | (flags 14 | (:standard \ -g)) 15 | (ocamlc_flags 16 | (:standard \ -g)) 17 | (link_flags 18 | (:standard \ -g)))) 19 | 20 | (rule 21 | (targets version.ml.in) 22 | (action 23 | (with-stdout-to 24 | %{targets} 25 | (run 26 | %{dep:tools/version/gen/gen.exe} 27 | %{dep:VERSION} 28 | %{dep:tools/version/GIT-VERSION})))) 29 | 30 | (data_only_dirs _wikidoc doc-dev) 31 | -------------------------------------------------------------------------------- /examples/graph_viewer/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names viewer_js) ;; add converter & viewer 3 | (libraries js_of_ocaml-lwt) 4 | (modes byte) 5 | (modules 6 | (:standard 7 | \ 8 | scene_extents 9 | svg 10 | main 11 | viewer 12 | converter 13 | dot_lexer 14 | dot_graph 15 | dot_render)) 16 | (preprocess 17 | (pps js_of_ocaml-ppx))) 18 | 19 | (ocamllex dot_lexer) 20 | 21 | (rule 22 | (targets viewer_js.js) 23 | (action 24 | (run 25 | %{bin:js_of_ocaml} 26 | --source-map 27 | %{dep:viewer_js.bc} 28 | -o 29 | %{targets} 30 | --pretty 31 | --file 32 | %{dep:scene.json}))) 33 | 34 | (alias 35 | (name default) 36 | (deps viewer_js.js index.html)) 37 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test6.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | | F : unit t 9 | 10 | let () = 11 | let ok1 = ref false 12 | and ok2 = ref true 13 | and ok3 = ref false in 14 | let f e r = 15 | try perform e with 16 | | Unhandled E -> r := not !r 17 | in 18 | f E ok1; 19 | Printf.printf "%b\n%!" !ok1; 20 | 21 | begin try f F ok2 with Unhandled _ -> () end; 22 | Printf.printf "%b\n%!" !ok2; 23 | 24 | try_with (f E) ok3 { 25 | effc = fun (type a) (e : a t) -> 26 | match e with 27 | | F -> Some (fun k -> assert false) 28 | | _ -> None 29 | }; 30 | Printf.printf "%b\n%!" !ok3 31 | -------------------------------------------------------------------------------- /lib/js_of_ocaml/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name js_of_ocaml) 3 | (public_name js_of_ocaml) 4 | (libraries js_of_ocaml-compiler.runtime) 5 | (foreign_stubs 6 | (language c) 7 | (names js_of_ocaml_stubs)) 8 | (preprocess 9 | (pps ppx_js_internal))) 10 | 11 | (rule 12 | (targets js_of_ocaml_stubs.c) 13 | (deps 14 | (:jsoo 15 | (glob_files *.ml)) 16 | (:runtime 17 | (glob_files ../runtime/*.ml))) 18 | (mode promote) 19 | (action 20 | (with-stdout-to 21 | %{targets} 22 | (run ../gen_stubs/gen_stubs.exe %{jsoo} --except %{runtime})))) 23 | 24 | (rule 25 | (targets lib_version.ml) 26 | (deps 27 | (:input-file ../../version.ml.in)) 28 | (action 29 | (copy %{input-file} %{targets}))) 30 | -------------------------------------------------------------------------------- /compiler/tests-dynlink-js/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (modules main) 4 | (libraries js_of_ocaml) 5 | (modes byte)) 6 | 7 | (rule 8 | (target main.js) 9 | (action 10 | (run %{bin:js_of_ocaml} --linkall -o %{target} %{dep:main.bc}))) 11 | 12 | (rule 13 | (target plugin.cmo) 14 | (action 15 | (run %{bin:ocamlc} -c %{dep:./plugin.ml}))) 16 | 17 | (rule 18 | (target plugin.js) 19 | (action 20 | (run %{bin:js_of_ocaml} %{dep:./plugin.cmo}))) 21 | 22 | (rule 23 | (target main.out) 24 | (deps plugin.js) 25 | (action 26 | (with-outputs-to 27 | %{target} 28 | (run %{bin:node} %{dep:./main.js})))) 29 | 30 | (rule 31 | (alias runtest) 32 | (action 33 | (diff main.out.expected main.out))) 34 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/marshal.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : string t 8 | 9 | let _ = 10 | try_with perform E 11 | { effc = fun (type a) (e : a t) -> 12 | Some (fun k -> 13 | (* We have to make sure that neither the match nor the call 14 | to Marshal.to_string are eliminated, so we call 15 | print_string and we print the result of the marshalling 16 | function. *) 17 | match print_string ""; 18 | Stdlib.Marshal.to_string k [] with 19 | | x -> Printf.printf "%S" x; assert false 20 | | exception (Invalid_argument _) -> print_endline "ok"; "" 21 | ) } 22 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/calc_parser.mly: -------------------------------------------------------------------------------- 1 | %token INT 2 | %token PLUS MINUS TIMES DIV 3 | %token LPAREN RPAREN 4 | %token EOL 5 | %left PLUS MINUS /* lowest precedence */ 6 | %left TIMES DIV /* medium precedence */ 7 | %nonassoc UMINUS /* highest precedence */ 8 | %start main /* the entry point */ 9 | %type main 10 | %% 11 | main: 12 | expr EOL { $1 } 13 | ; 14 | expr: 15 | INT { $1 } 16 | | LPAREN expr RPAREN { $2 } 17 | | expr PLUS expr { $1 + $3 } 18 | | expr MINUS expr { $1 - $3 } 19 | | expr TIMES expr { $1 * $3 } 20 | | expr DIV expr { $1 / $3 } 21 | | MINUS expr %prec UMINUS { - $2 } 22 | ; 23 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/partial.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | exception Done 9 | 10 | let handle_partial f = 11 | try_with f () 12 | { effc = fun (type a) (e : a t) -> 13 | match e with 14 | | E -> Some (fun k -> assert false) 15 | | _ -> None } 16 | 17 | let f () x = perform E 18 | 19 | let () = 20 | match_with (handle_partial f) () 21 | { retc = (fun x -> assert false); 22 | exnc = (function 23 | | Done -> print_string "ok\n" 24 | | e -> raise e); 25 | effc = fun (type a) (e : a t) -> 26 | match e with 27 | | E -> Some (fun (k : (a, _) continuation) -> discontinue k Done) 28 | | _ -> None } 29 | -------------------------------------------------------------------------------- /examples/wiki/test.ml: -------------------------------------------------------------------------------- 1 | (* This is demo input for wiki. It will be loaded automatically into window on startup *) 2 | 3 | let test1 = 4 | "\n\n\ 5 | ====this is h4\n\n\ 6 | # number list el 1\n\ 7 | # number list e2 2 //with italic text\n\n\n\ 8 | //with italic\n\n\ 9 | * bullet list el1 ** with bold text\n\ 10 | * bullet list el2 ** with bold // and italic text\n\n\ 11 | <>\n\n\ 12 | [[http://ya.ru|Link to Yandex]]\n\n\ 13 | [[http://google.com]]\n\n\ 14 | {{http://icons-search.com/img/yellowicon/firefox_win.zip/Firefox_Thunderbird_Win-icons-Firefox.ico-128x128.png|mail \ 15 | icon}}\n\n\ 16 | {{{\n\ 17 | == [[Nowiki]]:\n\ 18 | //**don't** format//\n\ 19 | }}}\n\n\n" 20 | -------------------------------------------------------------------------------- /tools/emacs-format-js.el: -------------------------------------------------------------------------------- 1 | ;;; File: emacs-format-file 2 | ;;; Stan Warford 3 | ;;; 17 May 2006 4 | 5 | (setq js-indent-level 2) 6 | (custom-set-variables 7 | '(indent-tabs-mode nil) 8 | '(tab-width 2)) 9 | 10 | (defun emacs-format-js () 11 | "Format the whole buffer." 12 | (js-mode) 13 | (indent-region (point-min) (point-max) nil) 14 | (delete-trailing-whitespace) 15 | (save-buffer) 16 | ) 17 | 18 | (defun emacs-format-js-ident () 19 | "Format the whole buffer." 20 | (js-mode) 21 | (indent-region (point-min) (point-max) nil) 22 | (save-buffer) 23 | ) 24 | 25 | (defun emacs-format-js-clean () 26 | "Format the whole buffer." 27 | (js-mode) 28 | (delete-trailing-whitespace) 29 | (save-buffer) 30 | ) 31 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/manylive.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | let f x = 5 | let a0 = ref 1 in 6 | let a1 = ref 1 in 7 | let a2 = ref 1 in 8 | let a3 = ref 1 in 9 | let a4 = ref 1 in 10 | let a5 = ref 1 in 11 | let a6 = ref 1 in 12 | let a7 = ref 1 in 13 | let a8 = ref 1 in 14 | let a9 = ref 1 in 15 | let a10 = ref 1 in 16 | let a11 = ref 1 in 17 | let a12 = ref 1 in 18 | if x then raise Not_found; 19 | [| a0; a1; a2; a3; a4; a5; a6; a7; a8; a9; a10; a11; a12 |] 20 | 21 | let () = 22 | for i = 1 to 50000 do 23 | let rs = Sys.opaque_identity f false in 24 | assert (Array.for_all (fun x -> !x = 1) rs); 25 | let _ = Array.make (Random.int 30) 'a' in () 26 | done; 27 | print_string "ok\n" 28 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-int64/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test issue9460) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target test.referencejs) 8 | (deps test.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./test.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps test.reference test.referencejs) 17 | (action 18 | (diff test.reference test.referencejs))) 19 | 20 | (rule 21 | (target issue9460.referencejs) 22 | (deps issue9460.bc.js) 23 | (action 24 | (with-stdout-to 25 | %{target} 26 | (run node ./issue9460.bc.js)))) 27 | 28 | (rule 29 | (alias runtest) 30 | (deps issue9460.reference issue9460.referencejs) 31 | (action 32 | (diff issue9460.reference issue9460.referencejs))) 33 | -------------------------------------------------------------------------------- /compiler/tests-dynlink/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (modules main) 4 | (libraries dynlink js_of_ocaml-compiler.dynlink) 5 | (modes byte)) 6 | 7 | (rule 8 | (target main.js) 9 | (deps plugin.cmo export) 10 | (action 11 | (run 12 | %{bin:js_of_ocaml} 13 | --dynlink 14 | --export 15 | export 16 | --pretty 17 | -o 18 | %{target} 19 | %{dep:main.bc}))) 20 | 21 | (rule 22 | (target plugin.cmo) 23 | (action 24 | (run %{bin:ocamlc} -c %{dep:./plugin.ml}))) 25 | 26 | (rule 27 | (target main.out) 28 | (deps plugin.cmo) 29 | (action 30 | (with-outputs-to 31 | %{target} 32 | (run %{bin:node} %{dep:./main.js})))) 33 | 34 | (rule 35 | (alias runtest) 36 | (action 37 | (diff main.out.expected main.out))) 38 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-set/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names testmap testset) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target testmap.referencejs) 8 | (deps testmap.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./testmap.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps testmap.reference testmap.referencejs) 17 | (action 18 | (diff testmap.reference testmap.referencejs))) 19 | 20 | (rule 21 | (target testset.referencejs) 22 | (deps testset.bc.js) 23 | (action 24 | (with-stdout-to 25 | %{target} 26 | (run node ./testset.bc.js)))) 27 | 28 | (rule 29 | (alias runtest) 30 | (deps testset.reference testset.referencejs) 31 | (action 32 | (diff testset.reference testset.referencejs))) 33 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-revapply/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names apply revapply) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target apply.referencejs) 8 | (deps apply.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./apply.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps apply.reference apply.referencejs) 17 | (action 18 | (diff apply.reference apply.referencejs))) 19 | 20 | (rule 21 | (target revapply.referencejs) 22 | (deps revapply.bc.js) 23 | (action 24 | (with-stdout-to 25 | %{target} 26 | (run node ./revapply.bc.js)))) 27 | 28 | (rule 29 | (alias runtest) 30 | (deps revapply.reference revapply.referencejs) 31 | (action 32 | (diff revapply.reference revapply.referencejs))) 33 | -------------------------------------------------------------------------------- /toplevel/test/test_toplevel.ml: -------------------------------------------------------------------------------- 1 | let () = Js_of_ocaml_toplevel.JsooTop.initialize () 2 | 3 | let fmt = Format.std_formatter 4 | 5 | let () = 6 | Js_of_ocaml.Sys_js.set_channel_flusher stderr (fun str -> Printf.printf ": %s" str) 7 | 8 | let () = 9 | Js_of_ocaml_toplevel.JsooTop.execute 10 | true 11 | ~pp_code:fmt 12 | ~highlight_location:(fun _ -> ()) 13 | fmt 14 | {| 15 | external parseInt : float -> int = "parseInt" 16 | let f = 3.14 17 | let () = Printf.printf "parseInt(%f) = %d\n" f (parseInt f);; 18 | |} 19 | 20 | let () = 21 | Js_of_ocaml_toplevel.JsooTop.execute 22 | true 23 | ~pp_code:fmt 24 | ~highlight_location:(fun _ -> ()) 25 | fmt 26 | {| 27 | let () = print_endline "hello";; 28 | 1+;;|} 29 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-bigarray/weak_bigarray.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | (** check that custom block are not copied by Weak.get_copy *) 5 | 6 | open Bigarray 7 | open Bigarray.Array1 8 | 9 | let () = 10 | let a = ref (create float64 c_layout 10) in 11 | Gc.compact (); 12 | set !a 0 42.; 13 | 14 | let w = Weak.create 1 in 15 | Weak.set w 0 (Some !a); 16 | 17 | let b = 18 | match Weak.get_copy w 0 with 19 | | None -> assert false 20 | | Some b -> b 21 | in 22 | Printf.printf "a.(0) = %f\n" (get !a 0); 23 | Printf.printf "b.(0) = %f\n" (get b 0); 24 | a := create float64 c_layout 10; 25 | Gc.compact (); 26 | 27 | let c = create float64 c_layout 10 in 28 | set c 0 33.; 29 | Printf.printf "b.(0) = %f\n" (get b 0); 30 | -------------------------------------------------------------------------------- /manual/install.wiki: -------------------------------------------------------------------------------- 1 | = Installation = 2 | == Requirements = 3 | * dune 4 | * Cmdliner, ppxlib 5 | 6 | See opam files at the root of the repository for version constraints. 7 | 8 | Optional dependencies: 9 | * tyxml, see https://github.com/ocsigen/tyxml 10 | * reactiveData, see https://github.com/ocsigen/reactiveData 11 | * yojson, see https://github.com/mjambon/yojson 12 | 13 | == Install from opam 14 | {{{opam install js_of_ocaml js_of_ocaml-ppx js_of_ocaml-lwt}}} 15 | 16 | == Build and install from source 17 | {{{ 18 | make 19 | }}} 20 | {{{ 21 | opam-installer js_of_ocaml-compiler 22 | }}} 23 | {{{ 24 | opam-installer js_of_ocaml 25 | }}} 26 | {{{ 27 | opam-installer js_of_ocaml-ppx 28 | }}} 29 | {{{ 30 | opam-installer js_of_ocaml-lwt 31 | }}} 32 | -------------------------------------------------------------------------------- /compiler/tests-sourcemap/dune: -------------------------------------------------------------------------------- 1 | (env 2 | (_ 3 | (js_of_ocaml 4 | (compilation_mode separate)))) 5 | 6 | (executable 7 | (name test) 8 | (modules test) 9 | (modes js) 10 | (libraries testlib)) 11 | 12 | (library 13 | (name testlib) 14 | (modules a b c d)) 15 | 16 | (executable 17 | (name dump_sourcemap) 18 | (modules dump_sourcemap) 19 | (libraries js_of_ocaml-compiler)) 20 | 21 | (rule 22 | (target dump) 23 | (enabled_if 24 | (<> %{profile} using-effects)) 25 | (action 26 | (with-stdout-to 27 | %{target} 28 | (run ./dump_sourcemap.exe %{dep:test.bc.js})))) 29 | 30 | (rule 31 | (alias runtest) 32 | (enabled_if 33 | (<> %{profile} using-effects)) 34 | (deps dump.reference dump) 35 | (action 36 | (diff dump.reference dump))) 37 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-filename/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names suffix extension) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target suffix.referencejs) 8 | (deps suffix.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./suffix.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps suffix.reference suffix.referencejs) 17 | (action 18 | (diff suffix.reference suffix.referencejs))) 19 | 20 | (rule 21 | (target extension.referencejs) 22 | (deps extension.bc.js) 23 | (action 24 | (with-stdout-to 25 | %{target} 26 | (run node ./extension.bc.js)))) 27 | 28 | (rule 29 | (alias runtest) 30 | (deps extension.reference extension.referencejs) 31 | (action 32 | (diff extension.reference extension.referencejs))) 33 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-format/print_if_newline.ml: -------------------------------------------------------------------------------- 1 | (* TEST *) 2 | 3 | (* 4 | 5 | A test file for Format.print_if_newline. 6 | 7 | *) 8 | 9 | open Format;; 10 | 11 | printf "\ntest print_if_newline\n%!"; 12 | printf " newline here\n%!"; 13 | print_if_newline (); 14 | printf " this gets printed"; 15 | print_if_newline (); 16 | printf " this doesn't get printed"; 17 | 18 | printf "\nprint_if_newline doesn't crash when last statement\n%!"; 19 | printf " newline here\n"; 20 | (* Important that the following is the last statement in the file. 21 | 22 | [print_if_newline] sets up the Format module to skip printing 23 | the next printing command. However, it should not crash if there 24 | is no next printing statement. *) 25 | print_if_newline (); 26 | ;; 27 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-string/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test_string binary) 3 | (enabled_if 4 | (>= %{ocaml_version} 5)) 5 | (libraries) 6 | (modes js)) 7 | 8 | (rule 9 | (target test_string.referencejs) 10 | (enabled_if 11 | (>= %{ocaml_version} 5)) 12 | (deps test_string.bc.js) 13 | (action 14 | (with-stdout-to 15 | %{target} 16 | (run node ./test_string.bc.js)))) 17 | 18 | (rule 19 | (alias runtest) 20 | (enabled_if 21 | (>= %{ocaml_version} 5)) 22 | (deps test_string.reference test_string.referencejs) 23 | (action 24 | (diff test_string.reference test_string.referencejs))) 25 | 26 | (rule 27 | (alias runtest) 28 | (enabled_if 29 | (>= %{ocaml_version} 5)) 30 | (deps binary.bc.js) 31 | (action 32 | (run node binary.bc.js))) 33 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test2.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Printf 5 | open Effect 6 | open Effect.Deep 7 | 8 | type _ t += E : int -> int t 9 | 10 | let f () = 11 | printf "perform effect (E 0)\n%!"; 12 | let v = perform (E 0) in 13 | printf "perform returns %d\n%!" v; 14 | v + 1 15 | 16 | let h : type a. a t -> ((a, 'b) continuation -> 'b) option = function 17 | | E v -> Some (fun k -> 18 | printf "caught effect (E %d). continuing..\n%!" v; 19 | let v = continue k (v + 1) in 20 | printf "continue returns %d\n%!" v; 21 | v + 1) 22 | | e -> None 23 | 24 | let v = 25 | match_with f () 26 | { retc = (fun v -> printf "done %d\n%!" v; v + 1); 27 | exnc = (fun e -> raise e); 28 | effc = h } 29 | 30 | let () = printf "result=%d\n%!" v 31 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/cmphash.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | 9 | let () = 10 | try_with perform E 11 | { effc = fun (type a) (e : a t) -> 12 | match e with 13 | | E -> Some (fun k -> 14 | (* We have to make sure that neither the match nor the call 15 | to caml_equal are eliminated, so we call 16 | print_string and we print the result of caml_equal. *) 17 | begin match print_string ""; k = k with 18 | | b -> Printf.printf "%b" b; assert false 19 | | exception (Invalid_argument _) -> print_endline "ok" 20 | end; 21 | begin match Hashtbl.hash k with 22 | | _ -> print_endline "ok" 23 | end) 24 | | e -> None } 25 | -------------------------------------------------------------------------------- /runtime/sync.js: -------------------------------------------------------------------------------- 1 | 2 | //Provides: MlMutex 3 | function MlMutex() { 4 | this.locked = false 5 | } 6 | 7 | //Provides: caml_ml_mutex_new 8 | //Requires: MlMutex 9 | function caml_ml_mutex_new(unit) { 10 | return new MlMutex(); 11 | } 12 | 13 | //Provides: caml_ml_mutex_lock 14 | //Requires: caml_failwith 15 | function caml_ml_mutex_lock(t) { 16 | if(t.locked) 17 | caml_failwith("Mutex.lock: mutex already locked. Cannot wait."); 18 | else t.locked = true; 19 | return 0; 20 | } 21 | 22 | //Provides: caml_ml_mutex_try_lock 23 | function caml_ml_mutex_try_lock(t) { 24 | if(!t.locked) { 25 | t.locked = true; 26 | return 1; 27 | } 28 | return 0; 29 | } 30 | 31 | //Provides: caml_ml_mutex_unlock 32 | function caml_ml_mutex_unlock(t) { 33 | t.locked = false; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-format/print_seq.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | include testing 3 | *) 4 | 5 | (* 6 | 7 | A test file for the Format module. 8 | 9 | *) 10 | 11 | open Testing;; 12 | open Format;; 13 | 14 | let say s = Printf.printf s;; 15 | 16 | let pp_print_intseq = pp_print_seq ~pp_sep:(fun fmt () -> pp_print_char fmt ' ') pp_print_int;; 17 | 18 | try 19 | 20 | say "empty\n%!"; 21 | test (asprintf "%a%!" pp_print_intseq Seq.empty = ""); 22 | 23 | say "\nmisc\n%!"; 24 | test (asprintf "%a" pp_print_intseq (List.to_seq [0]) = "0"); 25 | test (asprintf "%a" pp_print_intseq (List.to_seq [0;1;2]) = "0 1 2"); 26 | test (asprintf "%a" pp_print_intseq (List.to_seq [0;0]) = "0 0"); 27 | 28 | say "\nend of tests\n%!"; 29 | 30 | with e -> 31 | say "unexpected exception: %s\n%!" (Printexc.to_string e); 32 | test false; 33 | ;; 34 | -------------------------------------------------------------------------------- /benchmarks/sources/ml/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names 3 | almabench 4 | bdd 5 | binary_trees 6 | boyer 7 | boyer_no_exc 8 | fannkuch_redux_2 9 | fannkuch_redux 10 | fft 11 | fib 12 | hamming 13 | kb 14 | kb_no_exc 15 | loop 16 | nucleic 17 | quicksort 18 | raytrace 19 | soli 20 | splay 21 | takc 22 | taku)) 23 | 24 | (alias 25 | (name benchmark) 26 | (deps 27 | almabench.exe 28 | bdd.exe 29 | binary_trees.exe 30 | boyer.exe 31 | boyer_no_exc.exe 32 | fannkuch_redux_2.exe 33 | fannkuch_redux.exe 34 | fft.exe 35 | fib.exe 36 | hamming.exe 37 | kb.exe 38 | kb_no_exc.exe 39 | loop.exe 40 | nucleic.exe 41 | quicksort.exe 42 | raytrace.exe 43 | soli.exe 44 | splay.exe 45 | takc.exe 46 | taku.exe)) 47 | 48 | (env 49 | (_ 50 | (flags 51 | (:standard -w -32-34-38-69)))) 52 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | dune build @all 3 | 4 | tests: 5 | dune runtest 6 | 7 | test runtest runtests: tests 8 | 9 | doc: 10 | rm -rf doc-dev 11 | mkdir doc-dev 12 | dune clean 13 | dune build @doc --cache=disabled --force 14 | rsync -av --delete _build/default/_doc/_html/ doc-dev/api 15 | dune build @doc-manual --cache=disabled --force 16 | rsync -av --delete --exclude=".*" _build/default/manual/ doc-dev/manual 17 | find doc-dev/ -name dune -delete 18 | find doc-dev/ -name "*.exe" -delete 19 | 20 | promote: 21 | dune promote 22 | 23 | fmt: 24 | dune build @fmt --auto-promote 2> /dev/null || true 25 | git diff --exit-code 26 | 27 | clean: 28 | dune clean 29 | 30 | installdoc: 31 | git worktree add _wikidoc origin/wikidoc 32 | rsync -av doc-dev/ _wikidoc/doc/dev/ 33 | 34 | .PHONY: all tests test runtest runtests doc clean installdoc 35 | -------------------------------------------------------------------------------- /examples/boulderdash/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | All files contained in this directory and its sub-directories are 3 | distributed under the terms of the DO WHAT THE FUCK YOU WANT TO PUBLIC 4 | LICENSE (included below). 5 | 6 | ------------------------------------------------------------------------ 7 | 8 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 9 | Version 2, December 2004 10 | 11 | Copyright (C) 2004 Sam Hocevar 12 | 14 rue de Plaisance, 75014 Paris, France 13 | Everyone is permitted to copy and distribute verbatim or modified 14 | copies of this license document, and changing it is allowed as long 15 | as the name is changed. 16 | 17 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 18 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 19 | 20 | 0. You just DO WHAT THE FUCK YOU WANT TO. 21 | -------------------------------------------------------------------------------- /examples/minesweeper/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | All files contained in this directory and its sub-directories are 3 | distributed under the terms of the DO WHAT THE FUCK YOU WANT TO PUBLIC 4 | LICENSE (included below). 5 | 6 | ------------------------------------------------------------------------ 7 | 8 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 9 | Version 2, December 2004 10 | 11 | Copyright (C) 2004 Sam Hocevar 12 | 14 rue de Plaisance, 75014 Paris, France 13 | Everyone is permitted to copy and distribute verbatim or modified 14 | copies of this license document, and changing it is allowed as long 15 | as the name is changed. 16 | 17 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 18 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 19 | 20 | 0. You just DO WHAT THE FUCK YOU WANT TO. 21 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/test10.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += Peek : int t 8 | type _ t += Poke : unit t 9 | 10 | let rec a i = perform Peek + Random.int i 11 | let rec b i = a i + Random.int i 12 | let rec c i = b i + Random.int i 13 | 14 | let rec d i = 15 | Random.int i + 16 | try_with c i 17 | { effc = fun (type a) (e : a t) -> 18 | match e with 19 | | Poke -> Some (fun (k : (a,_) continuation) -> continue k ()) 20 | | _ -> None } 21 | 22 | let rec e i = 23 | Random.int i + 24 | try_with d i 25 | { effc = fun (type a) (e : a t) -> 26 | match e with 27 | | Peek -> Some (fun (k : (a,_) continuation) -> 28 | ignore (Deep.get_callstack k 100); 29 | continue k 42) 30 | | _ -> None } 31 | 32 | let _ = 33 | ignore (e 1); 34 | print_string "ok\n" 35 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-bigstring/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names bigstring_access string_access) 3 | (libraries) 4 | (modes js)) 5 | 6 | (rule 7 | (target bigstring_access.referencejs) 8 | (deps bigstring_access.bc.js) 9 | (action 10 | (with-stdout-to 11 | %{target} 12 | (run node ./bigstring_access.bc.js)))) 13 | 14 | (rule 15 | (alias runtest) 16 | (deps bigstring_access.reference bigstring_access.referencejs) 17 | (action 18 | (diff bigstring_access.reference bigstring_access.referencejs))) 19 | 20 | (rule 21 | (target string_access.referencejs) 22 | (deps string_access.bc.js) 23 | (action 24 | (with-stdout-to 25 | %{target} 26 | (run node ./string_access.bc.js)))) 27 | 28 | (rule 29 | (alias runtest) 30 | (deps string_access.reference string_access.referencejs) 31 | (action 32 | (diff string_access.reference string_access.referencejs))) 33 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-hashtbl/htbl.reference: -------------------------------------------------------------------------------- 1 | -- Random integers, large range 2 | Insertion: passed 3 | Insertion: passed 4 | Removal: passed 5 | -- Random integers, narrow range 6 | Insertion: passed 7 | Insertion: passed 8 | Removal: passed 9 | -- Strings, generic interface 10 | Insertion: passed 11 | Insertion: passed 12 | Removal: passed 13 | -- Strings, functorial interface 14 | Insertion: passed 15 | Insertion: passed 16 | Removal: passed 17 | -- Strings, functorial(String) interface 18 | Insertion: passed 19 | Insertion: passed 20 | Removal: passed 21 | -- Pairs of strings 22 | Insertion: passed 23 | Insertion: passed 24 | Removal: passed 25 | -- Lists of strings 26 | Insertion: passed 27 | Insertion: passed 28 | Removal: passed 29 | 1000 elements 30 | 100,2 31 | 200,4 32 | 300,6 33 | 400,8 34 | 500,10 35 | 600,12 36 | 700,14 37 | 800,16 38 | 900,18 39 | 1000,20 40 | 10 elements 41 | -------------------------------------------------------------------------------- /examples/graphics/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Graphics_js 7 | 8 | 9 | 20 | 21 | 22 | 23 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /lib/js_of_ocaml/js_of_ocaml_stubs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void caml_js_error_of_exception () { 4 | fprintf(stderr, "Unimplemented Javascript primitive caml_js_error_of_exception!\n"); 5 | exit(1); 6 | } 7 | void caml_js_get_console () { 8 | fprintf(stderr, "Unimplemented Javascript primitive caml_js_get_console!\n"); 9 | exit(1); 10 | } 11 | void caml_js_html_entities () { 12 | fprintf(stderr, "Unimplemented Javascript primitive caml_js_html_entities!\n"); 13 | exit(1); 14 | } 15 | void caml_js_html_escape () { 16 | fprintf(stderr, "Unimplemented Javascript primitive caml_js_html_escape!\n"); 17 | exit(1); 18 | } 19 | void caml_js_on_ie () { 20 | fprintf(stderr, "Unimplemented Javascript primitive caml_js_on_ie!\n"); 21 | exit(1); 22 | } 23 | void caml_xmlhttprequest_create () { 24 | fprintf(stderr, "Unimplemented Javascript primitive caml_xmlhttprequest_create!\n"); 25 | exit(1); 26 | } 27 | -------------------------------------------------------------------------------- /compiler/tests-jsoo/gh_1307.ml: -------------------------------------------------------------------------------- 1 | let test content = 2 | Printf.printf "input: %S\n" content; 3 | flush_all (); 4 | match Parser_1307.root Lexer_1307.token (Lexing.from_string content) with 5 | | n -> 6 | Printf.printf "%d\n" n; 7 | print_endline "success" 8 | | exception e -> 9 | print_endline (Printexc.to_string e); 10 | print_endline "failure" 11 | 12 | let%expect_test "parsing" = 13 | (* use [Parsing.set_trace true] once https://github.com/janestreet/ppx_expect/issues/43 is fixed *) 14 | let (old : bool) = Parsing.set_trace false in 15 | test "a"; 16 | [%expect {| 17 | input: "a" 18 | Stdlib.Parsing.Parse_error 19 | failure |}]; 20 | test "aa"; 21 | [%expect {| 22 | input: "aa" 23 | 0 24 | success |}]; 25 | test "aaa"; 26 | [%expect {| 27 | input: "aaa" 28 | Stdlib.Parsing.Parse_error 29 | failure |}]; 30 | let (_ : bool) = Parsing.set_trace old in 31 | () 32 | -------------------------------------------------------------------------------- /ppx/ppx_js/lib/ppx_js_rewriter.ml: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | include Ppx_js 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Boring file regexps: 2 | 3 | # Editor 4 | .vscode 5 | 6 | # C object files 7 | *.o 8 | *.a 9 | *.so 10 | # Ocaml object files 11 | *.cmi 12 | *.cmo 13 | *.cmx 14 | *.cma 15 | *.cmxa 16 | *.cmxs 17 | *.cmjs 18 | 19 | # generated by dune 20 | *.merlin 21 | *.install 22 | 23 | # backup files 24 | *~ 25 | *# 26 | .#* 27 | 28 | # Specific to Js_of_ocaml 29 | *.byte 30 | *.tmpjs 31 | *.map 32 | 33 | ocamltests 34 | 35 | gh-pages 36 | 37 | _opam 38 | _build 39 | 40 | # Benchmarks 41 | benchmarks/*.svg 42 | benchmarks/*.pdf 43 | benchmarks/__run 44 | benchmarks/build 45 | benchmarks/results 46 | benchmarks/config 47 | benchmarks/programs 48 | 49 | 50 | doc-dev 51 | _wikidoc 52 | 53 | toplevel/examples/lwt_toplevel_bin/*.cmis.js 54 | toplevel/examples/lwt_toplevel_bin/test_dynlink.js 55 | toplevel/examples/lwt_toplevel_bin/test_dynlink.cmi.js 56 | toplevel/examples/lwt_toplevel_bin/toplevel.js 57 | toplevel/examples/lwt_toplevel_bin/eval.js 58 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/prim-revapply/apply.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply" 5 | 6 | let f x = x + x 7 | let g x = x * x 8 | let h x = x + 1 9 | let add x y = x + y 10 | 11 | let _ = 12 | List.iter (fun x -> 13 | print_int x; print_newline () 14 | ) 15 | [ 16 | f @@ 3; (* 6 *) 17 | g @@ f @@ 3; (* 36 *) 18 | f @@ g @@ 3; (* 18 *) 19 | h @@ g @@ f @@ 3; (* 37 *) 20 | add 4 @@ g @@ f @@ add 3 @@ add 2 @@ 3; (* 260 *) 21 | ] 22 | external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply" 23 | 24 | let f x = x + x 25 | let g x = x * x 26 | let h x = x + 1 27 | let add x y = x + y 28 | 29 | let _ = 30 | List.iter (fun x -> 31 | print_int x; print_newline () 32 | ) 33 | [ 34 | f @@ 3; (* 6 *) 35 | g @@ f @@ 3; (* 36 *) 36 | f @@ g @@ 3; (* 18 *) 37 | h @@ g @@ f @@ 3; (* 37 *) 38 | add 4 @@ g @@ f @@ add 3 @@ add 2 @@ 3; (* 260 *) 39 | ] 40 | -------------------------------------------------------------------------------- /toplevel/test/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names test_toplevel) 3 | (libraries js_of_ocaml js_of_ocaml_toplevel) 4 | (flags 5 | (:standard -linkall)) 6 | (modes byte)) 7 | 8 | (rule 9 | (targets export.txt) 10 | (deps 11 | (package js_of_ocaml-toplevel)) 12 | (action 13 | (run jsoo_listunits -o %{targets} stdlib js_of_ocaml-toplevel))) 14 | 15 | (rule 16 | (targets test_toplevel.js) 17 | (action 18 | (run 19 | %{bin:js_of_ocaml} 20 | --export 21 | %{dep:export.txt} 22 | --toplevel 23 | --disable 24 | shortvar 25 | %{dep:test_toplevel.bc} 26 | -o 27 | %{targets}))) 28 | 29 | (rule 30 | (target test_toplevel.referencejs) 31 | (deps test_toplevel.js) 32 | (action 33 | (with-stdout-to 34 | %{target} 35 | (run node ./test_toplevel.js)))) 36 | 37 | (rule 38 | (alias runtest) 39 | (deps test_toplevel.reference test_toplevel.referencejs) 40 | (action 41 | (diff test_toplevel.reference test_toplevel.referencejs))) 42 | -------------------------------------------------------------------------------- /compiler/bin-js_of_ocaml/js_of_ocaml.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | -------------------------------------------------------------------------------- /compiler/bin-jsoo_minify/jsoo_minify.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | -------------------------------------------------------------------------------- /compiler/lib/lambda_lifting.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | val f : Code.program -> Code.program 20 | -------------------------------------------------------------------------------- /compiler/bin-js_of_ocaml/findlib_support.empty.ml: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | -------------------------------------------------------------------------------- /compiler/tests-io/cat.ml: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml tests 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2022 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | let () = input_line stdin |> output_string stdout 21 | -------------------------------------------------------------------------------- /toplevel/examples/eval/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 18 |
19 | 20 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /compiler/lib-findlib-support/jsoo_findlib_support.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | -------------------------------------------------------------------------------- /compiler/lib/js_assign.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | val program : Javascript.program -> Javascript.program 20 | -------------------------------------------------------------------------------- /ppx/ppx_js/lib/ppx_js_rewriter.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | (**/**) 20 | 21 | val mapper : Ast_mapper.mapper 22 | -------------------------------------------------------------------------------- /toplevel/examples/lwt_toplevel/colorize.fake.ml: -------------------------------------------------------------------------------- 1 | open Js_of_ocaml 2 | open Js_of_ocaml_tyxml 3 | 4 | let text ~a_class:cl s = Tyxml_js.Html.(span ~a:[ a_class [ cl ] ] [ txt s ]) 5 | 6 | let ocaml = text 7 | 8 | let highlight from_ to_ e = 9 | match Js.Opt.to_option e##.textContent with 10 | | None -> assert false 11 | | Some x -> 12 | let x = Js.to_string x in 13 | let (`Pos from_) = from_ in 14 | let to_ = 15 | match to_ with 16 | | `Pos n -> n 17 | | `Last -> String.length x - 1 18 | in 19 | e##.innerHTML := Js.string ""; 20 | let span kind s = 21 | if s <> "" 22 | then 23 | let span = Tyxml_js.Html.(span ~a:[ a_class [ kind ] ] [ txt s ]) in 24 | Dom.appendChild e (Tyxml_js.To_dom.of_element span) 25 | in 26 | span "normal" (String.sub x 0 from_); 27 | span "errorloc" (String.sub x from_ (to_ - from_)); 28 | span "normal" (String.sub x to_ (String.length x - to_)) 29 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-filename/suffix.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | let () = 5 | let test ~suffix name exp = 6 | let r1 = Filename.chop_suffix_opt ~suffix name <> None in 7 | let r2 = Filename.check_suffix name suffix in 8 | assert (r1 = r2); 9 | assert (r1 = exp) 10 | in 11 | let full_test ~suffix name = 12 | test ~suffix name true; 13 | match Filename.chop_suffix_opt ~suffix name with 14 | | None -> assert false 15 | | Some base -> assert (base ^ suffix = name) 16 | in 17 | let win32 = Sys.os_type = "Win32" || Sys.os_type = "Cygwin" in 18 | full_test ~suffix:".txt" "foo.txt"; 19 | full_test ~suffix:"txt" "foo.txt"; 20 | full_test ~suffix:"" "foo.txt"; 21 | full_test ~suffix:"" ""; 22 | test ~suffix:".txt" "f" false; 23 | test ~suffix:".txt" "" false; 24 | test ~suffix:".txt" "foo.txt.bak" false; 25 | test ~suffix:".txt" "foo.TXT" win32; 26 | if win32 then 27 | assert (Filename.chop_suffix_opt ~suffix:".txt" "foo.TXT" = Some "foo") 28 | -------------------------------------------------------------------------------- /ppx/ppx_js/as-lib/ppx_js.ml: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | include Ppx_js_internal 20 | 21 | let () = wrapper := Some "Js_of_ocaml" 22 | -------------------------------------------------------------------------------- /ppx/ppx_js/bin/main.ml: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | let () = Ppxlib.Driver.standalone () 21 | -------------------------------------------------------------------------------- /toplevel/lib/js_of_ocaml_toplevel.ml: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2017 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | module JsooTop = JsooTop 21 | -------------------------------------------------------------------------------- /toplevel/lib/jsooTopError.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2017 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val loc : exn -> Location.t option 21 | -------------------------------------------------------------------------------- /compiler/bin-js_of_ocaml/link.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val command : unit Cmdliner.Cmd.t 21 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-hashtbl/dune: -------------------------------------------------------------------------------- 1 | (executables 2 | (names hfun) 3 | (modules hfun) 4 | (libraries) 5 | (modes js)) 6 | 7 | (executables 8 | (names htbl) 9 | (modules htbl) 10 | (enabled_if 11 | (>= %{ocaml_version} 5)) 12 | (libraries) 13 | (modes js)) 14 | 15 | (rule 16 | (target hfun.referencejs) 17 | (deps hfun.bc.js ../../../LICENSE) 18 | (action 19 | (with-stdout-to 20 | %{target} 21 | (run node ./hfun.bc.js)))) 22 | 23 | (rule 24 | (alias runtest) 25 | (deps hfun.referencejs hfun.reference) 26 | (action 27 | (diff hfun.referencejs hfun.reference))) 28 | 29 | (rule 30 | (target htbl.referencejs) 31 | (enabled_if 32 | (>= %{ocaml_version} 5)) 33 | (deps htbl.bc.js ../../../LICENSE) 34 | (action 35 | (with-stdout-to 36 | %{target} 37 | (run node ./htbl.bc.js)))) 38 | 39 | (rule 40 | (alias runtest) 41 | (enabled_if 42 | (>= %{ocaml_version} 5)) 43 | (deps htbl.reference htbl.referencejs) 44 | (action 45 | (diff htbl.reference htbl.referencejs))) 46 | -------------------------------------------------------------------------------- /compiler/bin-js_of_ocaml/build_fs.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val command : unit Cmdliner.Cmd.t 21 | -------------------------------------------------------------------------------- /compiler/lib/annot_lexer.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2013 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val main : Lexing.lexbuf -> Annot_parser.token 21 | -------------------------------------------------------------------------------- /compiler/bin-js_of_ocaml/build_runtime.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val command : unit Cmdliner.Cmd.t 21 | -------------------------------------------------------------------------------- /compiler/bin-js_of_ocaml/print_runtime.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2020 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val command : unit Cmdliner.Cmd.t 21 | -------------------------------------------------------------------------------- /compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2022 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | (** Deliberately empty *) 21 | -------------------------------------------------------------------------------- /compiler/tests-ocaml/lib-effects/overflow.ml: -------------------------------------------------------------------------------- 1 | (* TEST 2 | *) 3 | 4 | open Effect 5 | open Effect.Deep 6 | 7 | type _ t += E : unit t 8 | 9 | let f a b c d e f g h = 10 | let bb = b + b in 11 | let bbb = bb + b in 12 | let cc = c + c in 13 | let ccc = cc + c in 14 | let dd = d + d in 15 | let ddd = dd + d in 16 | let ee = e + e in 17 | let eee = ee + e in 18 | let ff = f + f in 19 | let fff = ff + f in 20 | let gg = g + g in 21 | let ggg = gg + g in 22 | let hh = h + h in 23 | let hhh = hh + h in 24 | min 20 a + 25 | b + bb + bbb + 26 | c + cc + ccc + 27 | d + dd + ddd + 28 | e + ee + eee + 29 | f + ff + fff + 30 | g + gg + ggg + 31 | h + hh + hhh 32 | 33 | let () = 34 | match_with (fun _ -> f 1 2 3 4 5 6 7 8) () 35 | { retc = (fun n -> Printf.printf "%d\n" n); 36 | exnc = (fun e -> raise e); 37 | effc = fun (type a) (e : a t) -> 38 | match e with 39 | | E -> Some (fun k -> assert false) 40 | | _ -> None } 41 | -------------------------------------------------------------------------------- /examples/boulderdash/maps/level4.map: -------------------------------------------------------------------------------- 1 | ######################################## 2 | #...... ..+.X .....X.X....... ....X....# 3 | #.XSX...... .........X+..X.... ..... ..# 4 | #.......... ..X.....X.X..X........X....# 5 | #X.XX.........X......X..X....X...X.....# 6 | #X. X......... X..X........X......X.XX.# 7 | #... ..X........X.....X. X........X.XX.# 8 | ###############################...X..X.# 9 | #. ...X..+. ..X.X..........+.X+...... .# 10 | #..+.....X..... ........XX X..X....X...# 11 | #...X..X.X..............X .X..X........# 12 | #.X.....X........XXX.......X.. .+....X.# 13 | #.+.. ..X. .....X.X+..+....X...X..+. .# 14 | #. X..............X X..X........+.....X# 15 | #........############################### 16 | # X.........X...+....X.....X...X.......# 17 | # X......... X..X........X......X.XX..E# 18 | #. ..X........X.....X. ....+...X.XX...# 19 | #....X+..X........X......X.X+......X...# 20 | #... ..X. ..X.XX.........X.X+...... ..X# 21 | #.+.... ..... ......... .X..X....X...X.# 22 | ######################################## 23 | -------------------------------------------------------------------------------- /examples/graph_viewer/dot_render.mli: -------------------------------------------------------------------------------- 1 | (* Graph viewer 2 | * Copyright (C) 2010 Jérôme Vouillon 3 | * Laboratoire PPS - CNRS Université Paris Diderot 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val f : Dot_graph.graph -> (float * float * float * float) * Scene.cairo_t 21 | -------------------------------------------------------------------------------- /examples/graph_viewer/dot_lexer.mli: -------------------------------------------------------------------------------- 1 | (* Graph viewer 2 | * Copyright (C) 2010 Jérôme Vouillon 3 | * Laboratoire PPS - CNRS Université Paris Diderot 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val reset : unit -> unit 21 | 22 | val token : Lexing.lexbuf -> Dot_parser.token 23 | -------------------------------------------------------------------------------- /examples/graph_viewer/viewer.mli: -------------------------------------------------------------------------------- 1 | (* Graph viewer 2 | * Copyright (C) 2010 Jérôme Vouillon 3 | * Laboratoire PPS - CNRS Université Paris Diderot 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | 20 | val create : ?full_screen:bool -> float * float * float * float -> Scene.cairo_t -> unit 21 | -------------------------------------------------------------------------------- /ppx/ppx_js/lib_internal/ppx_js_internal.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml library 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | (**/**) 20 | 21 | val wrapper : string option ref 22 | 23 | val mapper : Ast_mapper.mapper 24 | -------------------------------------------------------------------------------- /compiler/lib/effects.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | type cps_calls = Code.Var.Set.t 20 | 21 | val f : Code.program * Deadcode.variable_uses -> Code.program * cps_calls 22 | -------------------------------------------------------------------------------- /compiler/lib/reserved.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * Copyright (C) 2013 Hugo Heuzard 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation, with linking exception; 8 | * either version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | *) 19 | open Stdlib 20 | 21 | val keyword : StringSet.t 22 | 23 | val provided : StringSet.t 24 | -------------------------------------------------------------------------------- /compiler/lib/timer.mli: -------------------------------------------------------------------------------- 1 | (* Js_of_ocaml compiler 2 | * http://www.ocsigen.org/js_of_ocaml/ 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, with linking exception; 7 | * either version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 | *) 18 | 19 | type t 20 | 21 | val make : unit -> t 22 | 23 | val get : t -> float 24 | 25 | val print : Format.formatter -> t -> unit 26 | --------------------------------------------------------------------------------