From a267b47bdf256a6981d57f74b5b7897b5742ba99 Mon Sep 17 00:00:00 2001 From: Oscar Spencer Date: Wed, 9 Oct 2024 20:14:47 -0500 Subject: [PATCH] make small function for internal names in linkedtree --- compiler/src/codegen/linkedtree.re | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/src/codegen/linkedtree.re b/compiler/src/codegen/linkedtree.re index 78e335c0d..1f9f00563 100644 --- a/compiler/src/codegen/linkedtree.re +++ b/compiler/src/codegen/linkedtree.re @@ -29,6 +29,12 @@ let max_stack_size = (s1, s2) => { let wasi_module = "wasi_snapshot_preview1"; +// Generates the name for the internal symbol. Symbols are scoped using the +// dependency ID for that module. +let internal_name = (id, dep_id) => { + Printf.sprintf("%s_%d", id, dep_id); +}; + let link = main_mashtree => { let main_module = Module_resolution.current_filename^(); @@ -144,7 +150,7 @@ let link = main_mashtree => { switch (export) { | WasmFunctionExport({ex_function_name, ex_function_internal_name}) => let internal_name = - Printf.sprintf("%s_%d", ex_function_internal_name, dep_id^); + internal_name(ex_function_internal_name, dep_id^); Hashtbl.add( func_export_resolutions, (dep, ex_function_name), @@ -159,8 +165,7 @@ let link = main_mashtree => { ); }; | WasmGlobalExport({ex_global_name, ex_global_internal_name}) => - let internal_name = - Printf.sprintf("%s_%d", ex_global_internal_name, dep_id^); + let internal_name = internal_name(ex_global_internal_name, dep_id^); Hashtbl.add( global_export_resolutions, (dep, ex_global_name),