| ... | @@ -352,6 +352,7 @@ struct AnalDumpCtx { | ... | @@ -352,6 +352,7 @@ struct AnalDumpCtx { |
| 352 | | 352 | |
| 353 | ZigList<ZigFn *> fn_list; | 353 | ZigList<ZigFn *> fn_list; |
| 354 | HashMap<const ZigFn *, uint32_t, fn_ptr_hash, fn_ptr_eql> fn_map; | 354 | HashMap<const ZigFn *, uint32_t, fn_ptr_hash, fn_ptr_eql> fn_map; |
| | 355 | HashMap<const ZigFn *, uint32_t, fn_ptr_hash, fn_ptr_eql> fn_decl_map; |
| 355 | | 356 | |
| 356 | ZigList<AstNode *> node_list; | 357 | ZigList<AstNode *> node_list; |
| 357 | HashMap<const AstNode *, uint32_t, node_ptr_hash, node_ptr_eql> node_map; | 358 | HashMap<const AstNode *, uint32_t, node_ptr_hash, node_ptr_eql> node_map; |
| ... | @@ -491,6 +492,7 @@ static uint32_t anal_dump_get_decl_id(AnalDumpCtx *ctx, Tld *tld) { | ... | @@ -491,6 +492,7 @@ static uint32_t anal_dump_get_decl_id(AnalDumpCtx *ctx, Tld *tld) { |
| 491 | | 492 | |
| 492 | if (fn != nullptr) { | 493 | if (fn != nullptr) { |
| 493 | (void)anal_dump_get_type_id(ctx, fn->type_entry); | 494 | (void)anal_dump_get_type_id(ctx, fn->type_entry); |
| | 495 | ctx->fn_decl_map.put_unique(fn, decl_id); |
| 494 | } | 496 | } |
| 495 | break; | 497 | break; |
| 496 | } | 498 | } |
| ... | @@ -1050,6 +1052,31 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) { | ... | @@ -1050,6 +1052,31 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) { |
| 1050 | anal_dump_type_ref(ctx, ty->data.array.child_type); | 1052 | anal_dump_type_ref(ctx, ty->data.array.child_type); |
| 1051 | break; | 1053 | break; |
| 1052 | } | 1054 | } |
| | 1055 | case ZigTypeIdVector: { |
| | 1056 | jw_object_field(jw, "len"); |
| | 1057 | jw_int(jw, ty->data.vector.len); |
| | 1058 | |
| | 1059 | jw_object_field(jw, "elem"); |
| | 1060 | anal_dump_type_ref(ctx, ty->data.vector.elem_type); |
| | 1061 | break; |
| | 1062 | } |
| | 1063 | case ZigTypeIdAnyFrame: { |
| | 1064 | if (ty->data.any_frame.result_type != nullptr) { |
| | 1065 | jw_object_field(jw, "result"); |
| | 1066 | anal_dump_type_ref(ctx, ty->data.any_frame.result_type); |
| | 1067 | } |
| | 1068 | break; |
| | 1069 | } |
| | 1070 | case ZigTypeIdFnFrame: { |
| | 1071 | jw_object_field(jw, "fnName"); |
| | 1072 | jw_string(jw, buf_ptr(&ty->data.frame.fn->symbol_name)); |
| | 1073 | |
| | 1074 | jw_object_field(jw, "fn"); |
| | 1075 | anal_dump_fn_ref(ctx, ty->data.frame.fn); |
| | 1076 | break; |
| | 1077 | } |
| | 1078 | case ZigTypeIdInvalid: |
| | 1079 | zig_unreachable(); |
| 1053 | default: | 1080 | default: |
| 1054 | jw_object_field(jw, "name"); | 1081 | jw_object_field(jw, "name"); |
| 1055 | jw_string(jw, buf_ptr(&ty->name)); | 1082 | jw_string(jw, buf_ptr(&ty->name)); |
| ... | @@ -1173,6 +1200,12 @@ static void anal_dump_fn(AnalDumpCtx *ctx, ZigFn *fn) { | ... | @@ -1173,6 +1200,12 @@ static void anal_dump_fn(AnalDumpCtx *ctx, ZigFn *fn) { |
| 1173 | jw_object_field(jw, "type"); | 1200 | jw_object_field(jw, "type"); |
| 1174 | anal_dump_type_ref(ctx, fn->type_entry); | 1201 | anal_dump_type_ref(ctx, fn->type_entry); |
| 1175 | | 1202 | |
| | 1203 | auto entry = ctx->fn_decl_map.maybe_get(fn); |
| | 1204 | if (entry != nullptr) { |
| | 1205 | jw_object_field(jw, "decl"); |
| | 1206 | jw_int(jw, entry->value); |
| | 1207 | } |
| | 1208 | |
| 1176 | jw_end_object(jw); | 1209 | jw_end_object(jw); |
| 1177 | } | 1210 | } |
| 1178 | | 1211 | |
| ... | @@ -1187,6 +1220,7 @@ void zig_print_analysis_dump(CodeGen *g, FILE *f, const char *one_indent, const | ... | @@ -1187,6 +1220,7 @@ void zig_print_analysis_dump(CodeGen *g, FILE *f, const char *one_indent, const |
| 1187 | ctx.decl_map.init(16); | 1220 | ctx.decl_map.init(16); |
| 1188 | ctx.node_map.init(16); | 1221 | ctx.node_map.init(16); |
| 1189 | ctx.fn_map.init(16); | 1222 | ctx.fn_map.init(16); |
| | 1223 | ctx.fn_decl_map.init(16); |
| 1190 | ctx.err_map.init(16); | 1224 | ctx.err_map.init(16); |
| 1191 | | 1225 | |
| 1192 | jw_begin_object(jw); | 1226 | jw_begin_object(jw); |