stage2: pass most test cases under InternPool

All but 2 test cases now pass (tested on x86_64 Linux, native only). The
remaining two signify an issue requiring a larger refactor, which I will
do in a separate commit.

Notable changes:
* Fix uninitialized memory when allocating objects from free lists
* Implement TypedValue printing for pointers
* Fix some TypedValue printing logic
* Work around non-existence of InternPool.remove implementation
This commit is contained in:
mlugg
2023-06-03 15:46:16 +01:00
committed by Andrew Kelley
parent ab86b20248
commit 2a6b91874a
16 changed files with 233 additions and 58 deletions

View File

@@ -4374,7 +4374,8 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void {
.index = struct_index.toOptional(),
.namespace = new_namespace_index.toOptional(),
} });
errdefer mod.intern_pool.remove(struct_ty);
// TODO: figure out InternPool removals for incremental compilation
//errdefer mod.intern_pool.remove(struct_ty);
new_namespace.ty = struct_ty.toType();
file.root_decl = new_decl_index.toOptional();
@@ -5682,7 +5683,10 @@ fn markOutdatedDecl(mod: *Module, decl_index: Decl.Index) !void {
}
pub fn createNamespace(mod: *Module, initialization: Namespace) !Namespace.Index {
if (mod.namespaces_free_list.popOrNull()) |index| return index;
if (mod.namespaces_free_list.popOrNull()) |index| {
mod.allocated_namespaces.at(@enumToInt(index)).* = initialization;
return index;
}
const ptr = try mod.allocated_namespaces.addOne(mod.gpa);
ptr.* = initialization;
return @intToEnum(Namespace.Index, mod.allocated_namespaces.len - 1);