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