add -fdump-analysis to dump type information to json
This commit adds -fdump-analysis which creates a `$NAME-analysis.json` file with all of the finished semantic analysis that the stage1 compiler produced. It contains types, packages, declarations, and files. This is an initial implementation; some data will be missing. However it's easy to improve the implementation, which is in `src/dump_analysis.cpp`. The next step for #21 will be to create Zig code which parses this json file and creates user-facing HTML documentation. This feature has other uses, however; for example, it could be used for IDE integration features until the self-hosted compiler is available.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
#include "libc_installation.hpp"
|
||||
#include "userland.h"
|
||||
#include "glibc.hpp"
|
||||
#include "stack_report.hpp"
|
||||
#include "dump_analysis.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -64,6 +64,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
|
||||
" -fno-PIC disable Position Independent Code\n"
|
||||
" -ftime-report print timing diagnostics\n"
|
||||
" -fstack-report print stack size diagnostics\n"
|
||||
" -fdump-analysis write analysis.json file for use with zig docs\n"
|
||||
" --libc [file] Provide a file which specifies libc paths\n"
|
||||
" --name [name] override output name\n"
|
||||
" --output-dir [dir] override output directory (defaults to cwd)\n"
|
||||
@@ -479,6 +480,7 @@ int main(int argc, char **argv) {
|
||||
size_t ver_patch = 0;
|
||||
bool timing_info = false;
|
||||
bool stack_report = false;
|
||||
bool enable_dump_analysis = false;
|
||||
const char *cache_dir = nullptr;
|
||||
CliPkg *cur_pkg = allocate<CliPkg>(1);
|
||||
BuildMode build_mode = BuildModeDebug;
|
||||
@@ -662,6 +664,8 @@ int main(int argc, char **argv) {
|
||||
timing_info = true;
|
||||
} else if (strcmp(arg, "-fstack-report") == 0) {
|
||||
stack_report = true;
|
||||
} else if (strcmp(arg, "-fdump-analysis") == 0) {
|
||||
enable_dump_analysis = true;
|
||||
} else if (strcmp(arg, "--enable-valgrind") == 0) {
|
||||
valgrind_support = ValgrindSupportEnabled;
|
||||
} else if (strcmp(arg, "--disable-valgrind") == 0) {
|
||||
@@ -1138,6 +1142,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
g->enable_time_report = timing_info;
|
||||
g->enable_stack_report = stack_report;
|
||||
g->enable_dump_analysis = enable_dump_analysis;
|
||||
codegen_set_out_name(g, buf_out_name);
|
||||
codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);
|
||||
g->want_single_threaded = want_single_threaded;
|
||||
|
||||
Reference in New Issue
Block a user