This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,6 @@
(executables
(names technologic)
(libraries js_of_ocaml x)
(js_of_ocaml
(flags (:standard))
(javascript_files runtime.js)))

View file

@ -0,0 +1,3 @@
global.globalPrintFunction = function(x){
console.log(x);
}

View file

@ -0,0 +1,13 @@
module Js = Js_of_ocaml.Js
let _ =
print_endline X.buy_it;
let obj = Js.Unsafe.obj [|"name", Js.Unsafe.inject (Js.string Z.use_it)|] in
Printf.printf "%s\n%!" (X.print obj);
X.external_print (Js.string "break it");
(fun x ->
let global = Js.Unsafe.get Js.Unsafe.global "global" in
let globalPrintFunction : Js.js_string Js.t -> unit =
Js.Unsafe.get global "globalPrintFunction" in
globalPrintFunction x
) (Js.string "fix it")

View file

@ -0,0 +1 @@
let use_it = "use it"

View file

@ -0,0 +1 @@
(lang dune 1.11)

View file

@ -0,0 +1,7 @@
(library
(name x)
(libraries js_of_ocaml)
(public_name x)
(js_of_ocaml
(flags (--pretty)) (javascript_files runtime.js))
(c_names stubs))

View file

@ -0,0 +1,6 @@
//Provides: jsPrint
function jsPrint(x){
console.log(x);
}

View file

@ -0,0 +1,3 @@
#include <stdlib.h>
#include <stdio.h>
void jsPrint () { fprintf(stderr, "Unimplemented Javascript primitive myPrint!\n"); exit(1); }

View file

@ -0,0 +1,5 @@
module Js = Js_of_ocaml.Js
let buy_it = "buy " ^ Y.it
let print x = Js.to_string (Js.Unsafe.get x "name")
external external_print : Js.js_string Js.t -> unit = "jsPrint"

View file

@ -0,0 +1 @@
let it = "it"

View file

@ -0,0 +1,32 @@
Compilation using jsoo
$ dune build bin/technologic.bc.js @install --profile dev
$ node ./_build/default/bin/technologic.bc.js
buy it
use it
break it
fix it
$ dune build @install --profile release
$ node ./_build/default/bin/technologic.bc.js
buy it
use it
break it
fix it
Compilation using jsoo with disable_dynamically_linked_foreign_archives = true
$ cat >dune-workspace <<EOF
> (lang dune 2.0)
> (context
> (default (disable_dynamically_linked_foreign_archives true)))
> EOF
$ dune clean
$ dune build bin/technologic.bc.js @install --profile dev
Js_of_ocaml whole program compilation works with
disable_dynamically_linked_foreign_archives = true:
$ dune build bin/technologic.bc.js @install --profile release
We expect a runtime error when running this bc-for-jsoo file.
$ ! if dune exe bin/technologic.bc-for-jsoo ; then true ; else false ; fi 2> /dev/null