refactor: redefining assumptions about declarations

This commit is contained in:
Brett Broadhurst 2026-03-23 22:45:55 -06:00
parent be297047d1
commit 33e3c1c271
Failed to generate hash of commit
4 changed files with 210 additions and 202 deletions

View file

@ -122,12 +122,12 @@ pub const Compilation = struct {
}
break :fatal true;
} else fatal: {
sema.analyzeFile(.file_inst) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => break :fatal true,
// TODO: These errors should be handled...
else => |e| return e,
};
//sema.analyzeFile(.file_inst) catch |err| switch (err) {
// error.OutOfMemory => return error.OutOfMemory,
// error.AnalysisFail => break :fatal true,
// // TODO: These errors should be handled...
// else => |e| return e,
//};
break :fatal false;
};
return .{
@ -144,10 +144,8 @@ pub const Compilation = struct {
pub fn setupStoryRuntime(cu: *Compilation, gpa: std.mem.Allocator, story: *Story) !void {
assert(cu.errors.len == 0);
const globals_len = cu.ir.globals.len;
const constants_pool = &story.constants_pool;
try constants_pool.ensureUnusedCapacity(gpa, cu.constants.len);
try story.globals.ensureUnusedCapacity(gpa, @intCast(globals_len));
for (cu.constants) |constant| {
switch (constant) {
@ -164,10 +162,6 @@ pub const Compilation = struct {
},
}
}
for (cu.ir.globals) |global| {
const name_bytes = cu.ir.nullTerminatedString(global.name);
story.globals.putAssumeCapacity(name_bytes, null);
}
for (cu.knots) |*knot| {
const knot_name = cu.ir.nullTerminatedString(knot.name);
const runtime_chunk: *Object.ContentPath = try .create(story, .{
@ -177,7 +171,7 @@ pub const Compilation = struct {
.const_pool = try knot.constants.toOwnedSlice(gpa),
.bytes = try knot.bytecode.toOwnedSlice(gpa),
});
story.globals.putAssumeCapacity(knot_name, &runtime_chunk.base);
try story.globals.put(gpa, knot_name, &runtime_chunk.base);
}
story.string_bytes = cu.ir.string_bytes;
cu.ir.string_bytes = &.{};