Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
## Bug fixes
* Runtime: fix Dom_html.onIE (#1493)
* Runtime: add conversion functions + strict equality for compatibility with Wasm_of_ocaml (#1492)
* Runtime: Dynlink should be able to find symbols in jsoo_runtime #1517
* Compiler: fix global flow analysis (#1494)
* COmpiler: fix js parser/printer wrt async functions (#1515)
* Compiler: fix js parser/printer wrt async functions (#1515)

# 5.4.0 (2023-07-06) - Lille

Expand Down
21 changes: 15 additions & 6 deletions runtime/dynlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,41 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

//Provides: current_libs
var current_libs = [0, globalThis]
//Provides: get_current_libs
var current_libs;
function get_current_libs () {
if(!current_libs)
current_libs = [0, globalThis, globalThis.jsoo_runtime]
return current_libs
}

//Provides: caml_dynlink_open_lib
//Requires: current_libs, caml_failwith
//Requires: get_current_libs, caml_failwith
//Requires: caml_jsstring_of_string
function caml_dynlink_open_lib (_mode,file) {
var name = caml_jsstring_of_string(file);
console.log("Dynlink: try to open ", name);
//caml_failwith("file not found: "+name)
var current_libs = get_current_libs();
current_libs.push({});
return current_libs.length;
}

//Provides: caml_dynlink_close_lib
//Requires: current_libs
//Requires: get_current_libs
function caml_dynlink_close_lib (idx) {
var current_libs = get_current_libs();
current_libs[idx]=null;
return 0;
}

//Provides: caml_dynlink_lookup_symbol
//Requires: current_libs
//Requires: get_current_libs
//Requires: caml_jsstring_of_string
function caml_dynlink_lookup_symbol (idx, fun_name) {
var name = caml_jsstring_of_string(fun_name);
console.log("Dynlink: looking for symbol", name);
var current_libs = get_current_libs();
if(current_libs[idx] && current_libs[idx][name])
return {name: name, symbol: current_libs[idx][name]};
return 0;
Expand All @@ -56,8 +64,9 @@ function caml_dynlink_add_primitive (dll_addr) {
}

//Provides: caml_dynlink_get_current_libs
//Requires: current_libs
//Requires: get_current_libs
function caml_dynlink_get_current_libs () {
var current_libs = get_current_libs();
var len = current_libs.length;
var a = new Array(len);
for(var i=0; i < len; i++)
Expand Down