Skip to content

Commit

Permalink
make small function for internal names in linkedtree
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Oct 10, 2024
1 parent d03fdb7 commit a267b47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler/src/codegen/linkedtree.re
Original file line number Diff line number Diff line change
Expand Up @@ -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^();

Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit a267b47

Please sign in to comment.