| ... | ... | @@ -501,6 +501,9 @@ const DocData = struct { |
| 501 | 501 | privDecls: []usize = &.{}, // index into decls |
| 502 | 502 | pubDecls: []usize = &.{}, // index into decls |
| 503 | 503 | fields: ?[]Expr = null, // (use src->fields to find names) |
| 504 | line_number: usize, |
| 505 | outer_decl: usize, |
| 506 | ast: usize, |
| 504 | 507 | }, |
| 505 | 508 | ComptimeExpr: struct { name: []const u8 }, |
| 506 | 509 | ComptimeFloat: struct { name: []const u8 }, |
| ... | ... | @@ -523,6 +526,7 @@ const DocData = struct { |
| 523 | 526 | src: usize, // index into astNodes |
| 524 | 527 | privDecls: []usize = &.{}, // index into decls |
| 525 | 528 | pubDecls: []usize = &.{}, // index into decls |
| 529 | ast: usize, |
| 526 | 530 | // (use src->fields to find field names) |
| 527 | 531 | }, |
| 528 | 532 | Union: struct { |
| ... | ... | @@ -531,6 +535,7 @@ const DocData = struct { |
| 531 | 535 | privDecls: []usize = &.{}, // index into decls |
| 532 | 536 | pubDecls: []usize = &.{}, // index into decls |
| 533 | 537 | fields: []Expr = &.{}, // (use src->fields to find names) |
| 538 | ast: usize, |
| 534 | 539 | }, |
| 535 | 540 | Fn: struct { |
| 536 | 541 | name: []const u8, |
| ... | ... | @@ -750,9 +755,9 @@ const DocData = struct { |
| 750 | 755 | }; |
| 751 | 756 | const SwitchOp = struct { |
| 752 | 757 | cond_index: usize, |
| 753 | | node_name: []const u8, |
| 754 | 758 | file_name: []const u8, |
| 755 | | line_start: usize, |
| 759 | ast: usize, |
| 760 | outer_decl: usize, // index in `types` |
| 756 | 761 | }; |
| 757 | 762 | const BuiltinBin = struct { |
| 758 | 763 | name: []const u8 = "", // fn name |
| ... | ... | @@ -1029,8 +1034,8 @@ fn walkInstruction( |
| 1029 | 1034 | // are already loaded at this point |
| 1030 | 1035 | if (file.pkg.table.get(path)) |other_package| { |
| 1031 | 1036 | const result = try self.packages.getOrPut(self.arena, other_package); |
| 1032 | | |
| 1033 | | // Immediately add this package to the import table of our |
| 1037 | |
| 1038 | // Immediately add this package to the import table of our |
| 1034 | 1039 | // current package, regardless of wether it's new or not. |
| 1035 | 1040 | if (self.packages.getPtr(file.pkg)) |current_package| { |
| 1036 | 1041 | // TODO: apparently, in the stdlib a file gets analized before |
| ... | ... | @@ -1062,7 +1067,6 @@ fn walkInstruction( |
| 1062 | 1067 | }, |
| 1063 | 1068 | }; |
| 1064 | 1069 | |
| 1065 | | |
| 1066 | 1070 | // TODO: Add this package as a dependency to the current pakcage |
| 1067 | 1071 | // TODO: this seems something that could be done in bulk |
| 1068 | 1072 | // at the beginning or the end, or something. |
| ... | ... | @@ -2043,19 +2047,21 @@ fn walkInstruction( |
| 2043 | 2047 | const cond_index = self.exprs.items.len; |
| 2044 | 2048 | _ = try self.walkRef(file, parent_scope, extra.data.operand, false); |
| 2045 | 2049 | |
| 2046 | | const ast_index = self.ast_nodes.items.len - 1; |
| 2047 | | const ast = self.ast_nodes.items[ast_index]; |
| 2050 | const ast_index = self.ast_nodes.items.len; |
| 2051 | const type_index = self.types.items.len - 1; |
| 2048 | 2052 | |
| 2049 | | // const sep = "=" ** 200; |
| 2050 | | // std.debug.print("{s}\n", .{sep}); |
| 2051 | | // std.debug.print("SWITCH BLOCK\n", .{}); |
| 2052 | | // std.debug.print("file path = {any}\n", .{file.sub_file_path}); |
| 2053 | | // std.debug.print("lazysrcloc = {any}\n", .{pl_node.src()}); |
| 2054 | | // std.debug.print("ast = {any}\n", .{ast}); |
| 2055 | | // std.debug.print("{s}\n", .{sep}); |
| 2053 | const ast_line = self.ast_nodes.items[ast_index - 1]; |
| 2054 | |
| 2055 | const sep = "=" ** 200; |
| 2056 | std.debug.print("{s}\n", .{sep}); |
| 2057 | std.debug.print("SWITCH BLOCK\n", .{}); |
| 2058 | std.debug.print("extra = {any}\n", .{extra}); |
| 2059 | std.debug.print("outer_decl = {any}\n", .{self.types.items[type_index]}); |
| 2060 | std.debug.print("ast_lines = {}\n", .{ast_line}); |
| 2061 | std.debug.print("{s}\n", .{sep}); |
| 2056 | 2062 | |
| 2057 | 2063 | const switch_index = self.exprs.items.len; |
| 2058 | | try self.exprs.append(self.arena, .{ .switchOp = .{ .cond_index = cond_index, .node_name = ast.name orelse "", .file_name = file.sub_file_path, .line_start = ast.line } }); |
| 2064 | try self.exprs.append(self.arena, .{ .switchOp = .{ .cond_index = cond_index, .file_name = file.sub_file_path, .ast = ast_index, .outer_decl = type_index } }); |
| 2059 | 2065 | |
| 2060 | 2066 | return DocData.WalkResult{ |
| 2061 | 2067 | .typeRef = .{ .type = @enumToInt(Ref.type_type) }, |
| ... | ... | @@ -2073,6 +2079,14 @@ fn walkInstruction( |
| 2073 | 2079 | const operand_index = self.exprs.items.len; |
| 2074 | 2080 | try self.exprs.append(self.arena, operand.expr); |
| 2075 | 2081 | |
| 2082 | const ast_index = self.ast_nodes.items.len; |
| 2083 | const sep = "=" ** 200; |
| 2084 | std.debug.print("{s}\n", .{sep}); |
| 2085 | std.debug.print("SWITCH COND\n", .{}); |
| 2086 | std.debug.print("ast index = {}\n", .{ast_index}); |
| 2087 | std.debug.print("ast previous = {}\n", .{self.ast_nodes.items[ast_index - 1]}); |
| 2088 | std.debug.print("{s}\n", .{sep}); |
| 2089 | |
| 2076 | 2090 | return DocData.WalkResult{ |
| 2077 | 2091 | .typeRef = operand.typeRef, |
| 2078 | 2092 | .expr = .{ .typeOf = operand_index }, |
| ... | ... | @@ -2633,13 +2647,7 @@ fn walkInstruction( |
| 2633 | 2647 | self.ast_nodes.items[self_ast_node_index].fields = field_name_indexes.items; |
| 2634 | 2648 | |
| 2635 | 2649 | self.types.items[type_slot_index] = .{ |
| 2636 | | .Union = .{ |
| 2637 | | .name = "todo_name", |
| 2638 | | .src = self_ast_node_index, |
| 2639 | | .privDecls = priv_decl_indexes.items, |
| 2640 | | .pubDecls = decl_indexes.items, |
| 2641 | | .fields = field_type_refs.items, |
| 2642 | | }, |
| 2650 | .Union = .{ .name = "todo_name", .src = self_ast_node_index, .privDecls = priv_decl_indexes.items, .pubDecls = decl_indexes.items, .fields = field_type_refs.items, .ast = self_ast_node_index }, |
| 2643 | 2651 | }; |
| 2644 | 2652 | |
| 2645 | 2653 | if (self.ref_paths_pending_on_types.get(type_slot_index)) |paths| { |
| ... | ... | @@ -2786,12 +2794,7 @@ fn walkInstruction( |
| 2786 | 2794 | self.ast_nodes.items[self_ast_node_index].fields = field_name_indexes.items; |
| 2787 | 2795 | |
| 2788 | 2796 | self.types.items[type_slot_index] = .{ |
| 2789 | | .Enum = .{ |
| 2790 | | .name = "todo_name", |
| 2791 | | .src = self_ast_node_index, |
| 2792 | | .privDecls = priv_decl_indexes.items, |
| 2793 | | .pubDecls = decl_indexes.items, |
| 2794 | | }, |
| 2797 | .Enum = .{ .name = "todo_name", .src = self_ast_node_index, .privDecls = priv_decl_indexes.items, .pubDecls = decl_indexes.items, .ast = self_ast_node_index }, |
| 2795 | 2798 | }; |
| 2796 | 2799 | if (self.ref_paths_pending_on_types.get(type_slot_index)) |paths| { |
| 2797 | 2800 | for (paths.items) |resume_info| { |
| ... | ... | @@ -2897,13 +2900,7 @@ fn walkInstruction( |
| 2897 | 2900 | self.ast_nodes.items[self_ast_node_index].fields = field_name_indexes.items; |
| 2898 | 2901 | |
| 2899 | 2902 | self.types.items[type_slot_index] = .{ |
| 2900 | | .Struct = .{ |
| 2901 | | .name = "todo_name", |
| 2902 | | .src = self_ast_node_index, |
| 2903 | | .privDecls = priv_decl_indexes.items, |
| 2904 | | .pubDecls = decl_indexes.items, |
| 2905 | | .fields = field_type_refs.items, |
| 2906 | | }, |
| 2903 | .Struct = .{ .name = "todo_name", .src = self_ast_node_index, .privDecls = priv_decl_indexes.items, .pubDecls = decl_indexes.items, .fields = field_type_refs.items, .line_number = self.ast_nodes.items[self_ast_node_index].line, .outer_decl = type_slot_index - 1, .ast = self_ast_node_index }, |
| 2907 | 2904 | }; |
| 2908 | 2905 | if (self.ref_paths_pending_on_types.get(type_slot_index)) |paths| { |
| 2909 | 2906 | for (paths.items) |resume_info| { |