-
Notifications
You must be signed in to change notification settings - Fork 18
Use table.clone instead of an empty table when reading structs #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rewrite
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have some concerns that I've left as comments, otherwise looks good!
compiler/codegen/init.luau
Outdated
|
||
builder:append(BUFFER_TEMPLATE) | ||
|
||
builder:append("-- upvalues start\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builder:append("-- upvalues start\n") | |
builder:append_line("-- upvalues start") |
compiler/codegen/init.luau
Outdated
for upval_id, default in lirr.upvalues do | ||
gen_upvalue(context, upval_id, default) | ||
end | ||
builder:append("-- upvalues end\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builder:append("-- upvalues end\n") | |
builder:append_line("-- upvalues end") |
compiler/lir/types.luau
Outdated
export type ProjShapedTable<T> = { | ||
write __phantom_type: T, | ||
|
||
type: "projection", | ||
kind: "shaped_table", | ||
base: LValue<T>, | ||
shape: { string }, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forget to remove this?
local function add_upvalue<T>(self: Builder, upvalue_name: string, upvalue_default: RValue<T>) | ||
local upval = upvalue(upvalue_name) | ||
self.ctx.lir.upvalues[upval] = upvalue_default | ||
|
||
return upval | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to have a panic here for duplicate upvalues entries
local ty = hir.ty_from_id(ctx.hir, decl.ty_id) | ||
|
||
if ty.kind == "struct" then | ||
local template = create_struct_template(decl.ty_id, ty) | ||
|
||
ctx.lir.upvalues[builders.fn.upvalue(tostring(decl.ty_id))] = template | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would need to build these in a different place (builders/ty possibly?) or we'd have to copy this segment for events and functs too.
This PR implements an optimization where a shaped table is cloned, instead of an empty completely dynamic table.
This also required the implementation of upvalues into codegen & LIR