From b0653b65632998750ffa0f49c44d317149a65b68 Mon Sep 17 00:00:00 2001 From: Niels Bross Date: Thu, 11 Sep 2025 17:29:45 +0200 Subject: [PATCH] Tracy --- .gitmodules | 3 ++ Semantic_Analysis.jai | 2 +- first.jai | 65 ++++++++++++++++++++++++++++++++++++++++--- modules/tracy | 1 + 4 files changed, 66 insertions(+), 5 deletions(-) create mode 160000 modules/tracy diff --git a/.gitmodules b/.gitmodules index fc261a2..5581d8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "modules/nbrutil"] path = modules/ncore url = git@git.nbross.com:nielsbross/NCore.git +[submodule "modules/tracy"] + path = modules/tracy + url = https://github.com/rluba/jai-tracy.git diff --git a/Semantic_Analysis.jai b/Semantic_Analysis.jai index 4b21b94..a6083dc 100644 --- a/Semantic_Analysis.jai +++ b/Semantic_Analysis.jai @@ -873,7 +873,7 @@ find_symbol :: (name : string, checker : *Semantic_Checker, containing_scope : * } from_handle :: (variables : []Type_Variable, handle : Type_Variable_Handle) -> *Type_Variable { - assert(handle > 0 && xx handle <= variables.count, tprint("Invalid handle: %. Range is: 1-%", handle, variables.count - 1)); + // assert(handle > 0 && xx handle <= variables.count, tprint("Invalid handle: %. Range is: 1-%", handle, variables.count - 1)); return *variables[handle - 1]; } diff --git a/first.jai b/first.jai index 4b46b3d..01e86a8 100644 --- a/first.jai +++ b/first.jai @@ -1,6 +1,9 @@ #import "Basic"; #import "File"; #import "Compiler"; +#import "Metaprogram_Plugins"; + +plugins: [..] *Metaprogram_Plugin; build :: () { w := compiler_create_workspace("Ink Build"); @@ -18,14 +21,45 @@ build :: () { args := options.compile_time_command_line; + intercept_flags: Intercept_Flags; + plugin_start_index := -1; + for arg : args { if arg == { case "check"; { options.output_type = .NO_OUTPUT; } } + + it := args[it_index]; + + if !it continue; + + if it[0] == #char "+" { + plugin_start_index = it_index; + } } + plugins_to_create: [..] Plugin_To_Create; + tracy : Plugin_To_Create; + tracy.name = "tracy"; + array_add(*plugins_to_create, tracy); + // got_error := false; + // if plugin_start_index >= 0 { + // success:, plugins_to_create = parse_plugin_arguments(args, plugin_start_index); + // if !success got_error = true; + // } + + // if got_error { + // exit(1); + // } + + success := init_plugins(plugins_to_create, *plugins, w); + if !success { + log_error("A plugin init() failed. Exiting.\n"); + exit(0); + } + new_path: [..] string; array_add(*new_path, ..options.import_path); array_add(*new_path, "modules"); @@ -35,18 +69,41 @@ build :: () { wd := get_working_directory(); - set_build_options(options, w); - compiler_begin_intercept(w); + for plugins { + if it.before_intercept it.before_intercept(it, *intercept_flags); + } + + compiler_begin_intercept(w, intercept_flags); + + for plugins if it.add_source it.add_source(it); add_build_file(MAIN_FILE, w); + // Call message_loop(), which is a routine of ours below that will receive the messages. + message_loop(w); + compiler_end_intercept(w); + for plugins if it.finish it.finish (it); + for plugins if it.shutdown it.shutdown(it); + print("\nDone!\n\n"); - set_build_options_dc(.{do_output=false}); + set_build_options_dc(.{do_output=false, write_added_strings=false}); } -#run build(); +message_loop :: (w: Workspace) { + while true { + // We ask the compiler for the next message. If one is not available, + // we will wait until it becomes available. + message := compiler_wait_for_message(); + // Pass the message to all plugins. + for plugins if it.message it.message(it, message); + + if message.kind == .COMPLETE break; + } +} + +#run, stallable build(); diff --git a/modules/tracy b/modules/tracy new file mode 160000 index 0000000..9668d7b --- /dev/null +++ b/modules/tracy @@ -0,0 +1 @@ +Subproject commit 9668d7b8abeea29db9e7b4f987fd2a113afe26e9