From 59ac7b91daed86af1ff03aceb7d9e9b8118e06ba Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 3 Oct 2019 17:58:22 -0400 Subject: 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. --- src/analyze.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 1282126fbc..cca239c275 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -7303,6 +7303,22 @@ bool type_ptr_eql(const ZigType *a, const ZigType *b) { return a == b; } +uint32_t pkg_ptr_hash(const ZigPackage *ptr) { + return hash_ptr((void*)ptr); +} + +bool pkg_ptr_eql(const ZigPackage *a, const ZigPackage *b) { + return a == b; +} + +uint32_t tld_ptr_hash(const Tld *ptr) { + return hash_ptr((void*)ptr); +} + +bool tld_ptr_eql(const Tld *a, const Tld *b) { + return a == b; +} + ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name) { Tld *tld = get_container_scope(codegen->compile_var_import)->decl_table.get(buf_create_from_str(name)); resolve_top_level_decl(codegen, tld, nullptr, false); -- cgit v1.2.3