-
Notifications
You must be signed in to change notification settings - Fork 26
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
Implement serialize #137
base: pz-write-tags
Are you sure you want to change the base?
Implement serialize #137
Conversation
2621c37
to
8968499
Compare
986bff5
to
bafe96f
Compare
ext/liquid_c/document_body.c
Outdated
VALUE str = rb_str_buf_new(sizeof(document_body_header_t) + buffer_len + constants_len); | ||
|
||
document_body_header_t header = { | ||
.entrypoint_block_index = entrypoint_block_index, |
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.
Should we add a bytecode/serialization version at the top? In case we need to make some backward incompatible changes to the bytecode.
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.
Yes. I suggested this in the deserialize PR here https://github.com/Shopify/liquid-c/pull/138/files#r551963712
ext/liquid_c/document_body.h
Outdated
@@ -28,6 +28,14 @@ typedef struct document_body { | |||
c_buffer_t buffer; | |||
} document_body_t; | |||
|
|||
typedef struct document_body_header { | |||
uint32_t entrypoint_block_index; |
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.
I see it's called index here, but it ends up being used as an offset here: https://github.com/Shopify/liquid-c/pull/138/files#diff-d25b9c9a1b16f1935c261f8232ea43e790513f022f33b7c8de117016cd76f130R188 correct?
Should this be renamed to _offset or the code is wrong in #138?
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.
You're right, it is an offset. There isn't currently a block table to index into.
bafe96f
to
0e8d1c2
Compare
0e8d1c2
to
f26621c
Compare
Based on #136.
This PR implements
BlockBody#dump
that dumps the block body to a string. The block body dumps the instructions, writes the tag markups to the buffer, and marshal dumps the constants into a single string that is returned.