refactor: working towards a better astgen patterns
This commit is contained in:
parent
d6ff3a40bd
commit
95d89b7bf9
7 changed files with 922 additions and 596 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue