17 static const ImGuiTableFlags kCallbackTableFlags
18 = ImGuiTableFlags_BordersV
19 | ImGuiTableFlags_BordersOuterH
20 | ImGuiTableFlags_Resizable
21 | ImGuiTableFlags_RowBg
22 | ImGuiTableFlags_NoHostExtendX
23 | ImGuiTableFlags_NoBordersInBody;
25 static std::string_view from_text_view(
const text_view_t& view)
27 return std::string_view(view.text, view.
length);
30 static void draw_version(
const char *
id,
ctu_version_t version)
36 ImGui::Text(
"%s: %d.%d.%d",
id, major, minor, patch);
39 static bool begin_table_node(
const void *ptr_id,
const char *label,
int columns, ImGuiTableFlags flags)
41 if (ImGui::TreeNode(ptr_id,
"%s", label))
43 if (ImGui::BeginTable(label, columns, flags))
56 static void end_table_node()
64 if (begin_table_node((
void*)&list,
"Diagnostics", 4, kCallbackTableFlags))
66 ImGui::TableSetupColumn(
"ID");
67 ImGui::TableSetupColumn(
"Severity");
68 ImGui::TableSetupColumn(
"Brief");
69 ImGui::TableSetupColumn(
"Description");
70 ImGui::TableHeadersRow();
72 for (
size_t i = 0; i < list.count; i++)
75 ImGui::TableNextRow();
76 ImGui::TableNextColumn();
77 ImGui::TextUnformatted(diag->
id);
79 ImGui::TableNextColumn();
82 ImGui::TableNextColumn();
83 ImGui::TextUnformatted(diag->
brief ? diag->
brief :
"no brief");
85 ImGui::TableNextColumn();
93 static void draw_feature(
const char *name,
bool supported)
95 ImGui::TextUnformatted(name);
99 ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f),
"Available");
103 ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f),
"Not Available");
116 ImGui::Text(
"ID: %s", info.
id);
119 ImGui::Text(
"License: %s", version.
license);
120 ImGui::Text(
"Description: %s", version.
desc);
121 ImGui::Text(
"Author: %s", version.
author);
122 draw_version(
"Version", version.
version);
133 void FrontendInfoPanel::draw_content()
146 for (
char& c : builtin)
if (c ==
'\0') c =
'/';
148 for (
size_t i = 0; lang.
exts[i]; i++)
150 if (i > 0) extensions +=
", ";
151 extensions += lang.
exts[i];
155 static float get_tooltip_width()
157 ImVec2 ttsize = ImGui::CalcTextSize(
"(?)");
161 static void draw_function_address(
const void *pfn)
165 ImVec4 orange = ImVec4(1.0f, 0.5f, 0.0f, 1.0f);
166 ImGui::TextColored(orange,
"Not provided");
170 ImGui::Text(
"0x%p", pfn);
174 static void draw_row(
const char *name,
const void *pfn,
const char *tooltip)
176 ImGui::TableNextRow();
177 ImGui::TableNextColumn();
178 ImGui::TextDisabled(
"(?)");
179 ImGui::SetItemTooltip(
"%s", tooltip);
181 ImGui::TableNextColumn();
182 ImGui::TextUnformatted(name);
184 ImGui::TableNextColumn();
185 draw_function_address(pfn);
188 void LanguageInfoPanel::draw_content()
190 float ttwidth = get_tooltip_width();
192 ImGui::Text(
"Default extensions: %s", extensions.c_str());
194 ImGui::Text(
"Context struct size: %zu", lang.
context_size);
195 ImGui::Text(
"AST struct size: %zu", lang.
ast_size);
197 if (begin_table_node((
void*)&lang.
builtin,
"Builtin", 2, kCallbackTableFlags))
199 ImGui::TableSetupColumn(
"Name");
200 ImGui::TableSetupColumn(
"Size");
201 ImGui::TableHeadersRow();
203 for (
size_t i = 0; i < lang.
builtin.length; i++)
205 const char *
id =
"no name";
208 ImGui::TableNextRow();
209 ImGui::TableNextColumn();
210 ImGui::TextUnformatted(
id ?
id :
"no name");
211 ImGui::TableNextColumn();
212 ImGui::Text(
"%zu", lang.
builtin.decls[i]);
217 if (begin_table_node((
void*)&lang,
"Callbacks", 3, kCallbackTableFlags))
219 ImGui::TableSetupColumn(
"Info", ImGuiTableColumnFlags_WidthFixed, ttwidth);
220 ImGui::TableSetupColumn(
"Name");
221 ImGui::TableSetupColumn(
"Address");
222 ImGui::TableHeadersRow();
224 draw_row(
"Create", (
const void*)lang.fn_create,
225 "Called during initial creation of the language driver.\n"
226 "Responsible for setting up any resources required for the language.");
228 draw_row(
"Destroy", (
const void*)lang.fn_destroy,
229 "Called during destruction of the language driver.\n"
230 "Responsible for cleaning up any resources allocated during creation or runtime.");
232 draw_row(
"Preparse", (
const void*)lang.fn_preparse,
233 "Called once before parsing each source file.\n"
234 "Configures parser and scanner local values for the source file.");
236 draw_row(
"Postparse", (
const void*)lang.fn_postparse,
237 "Called once after parsing each source file.\n"
238 "Responsible for producing translation units that will later be analyzed.");
244 ImGui::BeginDisabled(scan ==
nullptr);
246 if (begin_table_node((
void*)scan, ed::strfmt<64>(
"Scanner (0x%p)", scan), 3, kCallbackTableFlags))
248 ImGui::TableSetupColumn(
"Info", ImGuiTableColumnFlags_WidthFixed, ttwidth);
249 ImGui::TableSetupColumn(
"Name");
250 ImGui::TableSetupColumn(
"Address");
251 ImGui::TableHeadersRow();
253 draw_row(
"Init", (
const void*)scan->init,
254 "Called once during the creation of the scanner.\n"
255 "Responsible for setting up any resources required for the scanner.");
257 draw_row(
"Scan", (
const void*)scan->scan,
258 "Scans a source file and produces a token stream.\n"
259 "This token stream is required for parsing.");
261 draw_row(
"Parse", (
const void*)scan->parse,
262 "Parses a token stream and produces an ast.");
264 draw_row(
"Destroy Buffer", (
const void*)scan->destroy,
265 "Called during destruction of the scanner.\n"
266 "Responsible for cleaning up any resources allocated during creation or runtime.");
268 draw_row(
"Destroy", (
const void*)scan->destroy,
269 "Called during destruction of the scanner.\n"
270 "Responsible for cleaning up any resources allocated during creation or runtime.");
274 ImGui::EndDisabled();
278 ImGui::SetItemTooltip(
"This language does not provide a scanner");
281 if (begin_table_node((
void*)&lang.fn_passes,
"Passes", 3, kCallbackTableFlags))
283 ImGui::TableSetupColumn(
"Index", ImGuiTableColumnFlags_WidthFixed, 30.f);
284 ImGui::TableSetupColumn(
"Name");
285 ImGui::TableSetupColumn(
"Address");
286 ImGui::TableHeadersRow();
291 ImGui::TableNextRow();
292 ImGui::TableNextColumn();
293 ImGui::Text(
"%zu", i);
294 ImGui::TableNextColumn();
296 ImGui::TableNextColumn();
297 draw_function_address((
const void*)lang.fn_passes[i]);
310 void PluginInfoPanel::draw_content()
313 ImGui::Text(
"Create: %p", plugin.
fn_create);
314 ImGui::Text(
"Destroy: %p", plugin.
fn_destroy);
317 if (ImGui::TreeNode((
void*)&events,
"Events"))
319 for (
size_t i = 0; i < events.count; i++)
321 ImGui::BulletText(
"Event %zu: %d", i, events.events[i].event);
333 void TargetInfoPanel::draw_content()
336 ImGui::Text(
"Create: %p", target.
fn_create);
337 ImGui::Text(
"Destroy: %p", target.
fn_destroy);
338 draw_feature(
"Tree output", target.
fn_tree !=
nullptr);
339 draw_feature(
"SSA output", target.
fn_ssa !=
nullptr);
FrontendInfoPanel(const frontend_t &info)
LanguageInfoPanel(const language_t &lang)
ModuleInfoPanel(const module_info_t &info)
PluginInfoPanel(const plugin_t &plugin)
TargetInfoPanel(const target_t &target)
CT_CONSTFN CT_BROKER_API const char * broker_pass_name(broker_pass_t pass)
extra stuff
#define CT_VERSION_MAJOR(version)
returns the major version of version
uint_fast32_t ctu_version_t
underlying type for ctu_version_t
#define CT_VERSION_MINOR(version)
returns the minor version of version
#define CT_VERSION_PATCH(version)
returns the patch version of version
#define CT_UNUSED(x)
mark a variable as unused
STA_RET_STRING CT_CONSTFN CT_NOTIFY_API const char * severity_string(severity_t severity)
get the name of a severity
const char * brief
a brief description of the diagnostic a single line description of the diagnostic
const char * id
the id of the diagnostic should be in the format [A-Z]{2,3}[0-9]{4} e.g. CLI0001 this is not enforced...
severity_t severity
the severity of the diagnostic
const char * description
a description of the diagnostic a more involved description of the diagnostic this is optional
the frontend running the mediator
unit_id_t name
the name of the builtin module
a language driver support capabilities
const char *const * exts
the default file extensions this language should be used for
size_t context_size
the size of the scan context for this language
language_info_t builtin
builtin module configuration
size_t ast_size
the size of an ast node for this language
common information about anything the broker supports
version_info_t version
the version of the module
diagnostic_list_t diagnostics
all diagnostics associated with this module
const char * id
unique id for the module
plugin support capabilities
event_list_t events
the events this plugin is interested in
plugin_destroy_t fn_destroy
called at shutdown
plugin_create_t fn_create
called once at startup
scanner function callbacks for flex and bison
target_tree_t fn_tree
generate from the tree form
target_ssa_t fn_ssa
generate from the ssa form
target_destroy_t fn_destroy
called at shutdown
target_create_t fn_create
called once at startup
a non-owning view of text
size_t length
the number of characters in the text
version information for a driver/interface/plugin
const char * license
the license of this component
const char * author
the author of this component
const char * desc
a short description of this component
ctu_version_t version
the version info for this component