Skip to content

Instantly share code, notes, and snippets.

@kevinw
Created December 12, 2020 10:53
Show Gist options
  • Save kevinw/44b5c19464c31b36791f69c62f5d0375 to your computer and use it in GitHub Desktop.
Save kevinw/44b5c19464c31b36791f69c62f5d0375 to your computer and use it in GitHub Desktop.

run instructions

jai build.jai && module_test.exe

output

mod_a func (do_thing=false) is at procedure 0x7ff671b2f290
mod_a func (do_thing=false) is at procedure 0x7ff671b2f290
#scope_file
module_search_paths := string.[
".",
];
build :: () {
set_working_directory(#filepath);
opts := get_build_options();
opts.output_type = .NO_OUTPUT;
set_build_options(opts);
w := compiler_create_workspace("build");
{
compiler_begin_intercept(w);
defer compiler_end_intercept(w);
array_add(*opts.modules_search_path_array, ..module_search_paths);
opts.output_type = .EXECUTABLE;
opts.output_executable_name = "module_test.exe";
set_build_options(opts, w);
add_build_file("module_test.jai", w);
while true {
message := compiler_wait_for_message();
if !message || message.workspace != w continue;
if message.kind == .COMPLETE { break; }
}
}
};
#run build();
#import "Basic";
#import "Compiler";
#module_parameters(do_thing: bool);
print_where_storage_is :: () {
print("mod_a func (do_thing=%) is at %\n", do_thing, print_where_storage_is);
}
#scope_file
#import "Basic";
main :: () {
A :: #import "mod_a"(do_thing=true);
B :: #import "mod_a"(do_thing=false);
A.print_where_storage_is();
B.print_where_storage_is();
}
#scope_file
#import "Basic";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment