File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -42,15 +42,16 @@ function caml_dynlink_close_lib (idx) {
4242//Requires: caml_jsstring_of_string
4343function caml_dynlink_lookup_symbol ( idx , fun_name ) {
4444 var name = caml_jsstring_of_string ( fun_name ) ;
45- console . log ( "Dynlink: look for symbol " , name ) ;
45+ console . log ( "Dynlink: looking for symbol" , name ) ;
4646 if ( current_libs [ idx ] && current_libs [ idx ] [ name ] )
47- return current_libs [ idx ] [ name ] ;
47+ return { name : name , symbol : current_libs [ idx ] [ name ] } ;
4848 return 0 ;
4949}
5050
5151//Provides: caml_dynlink_add_primitive
5252//Requires: caml_global_data
5353function caml_dynlink_add_primitive ( dll_addr ) {
54+ globalThis . jsoo_runtime [ dll_addr . name ] = dll_addr . symbol ;
5455 return caml_global_data . prim_count ++ ;
5556}
5657
Original file line number Diff line number Diff line change @@ -5,6 +5,18 @@ let fmt = Format.std_formatter
55let () =
66 Js_of_ocaml.Sys_js. set_channel_flusher stderr (fun str -> Printf. printf " <ERR>: %s" str)
77
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+
820let () =
921 Js_of_ocaml_toplevel.JsooTop. execute
1022 true
Original file line number Diff line number Diff line change 11
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+
210let () = print_endline "hello";;
311hello
4121+;;
You can’t perform that action at this time.
0 commit comments