refactor: working towards a better astgen patterns

This commit is contained in:
Brett Broadhurst 2026-03-08 04:22:57 -06:00
parent d6ff3a40bd
commit 95d89b7bf9
Failed to generate hash of commit
7 changed files with 922 additions and 596 deletions

View file

@ -262,17 +262,23 @@ pub const Object = struct {
base: Object,
name: *Object.String,
arity: usize,
// TODO: Rename this to stack size.
locals_count: usize,
// TODO: Rename this to constant_pool.
const_pool: []*Object,
bytes: []const u8,
pub fn create(
story: *Story,
pub const CreateOptions = struct {
name: *Object.String,
arity: usize,
locals_count: usize,
const_pool: []*Object,
bytes: []const u8,
};
pub fn create(
story: *Story,
options: CreateOptions,
) error{OutOfMemory}!*ContentPath {
const gpa = story.allocator;
const alloc_len = @sizeOf(ContentPath);
@ -285,11 +291,11 @@ pub const Object = struct {
.is_marked = false,
.node = .{},
},
.name = name,
.arity = arity,
.locals_count = locals_count,
.const_pool = const_pool,
.bytes = bytes,
.name = options.name,
.arity = options.arity,
.locals_count = options.locals_count,
.const_pool = options.const_pool,
.bytes = options.bytes,
};
story.gc_objects.prepend(&object.base.node);