Skip to content

Conversation

@peterzhu2118
Copy link
Contributor

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.

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,
Copy link
Contributor

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.

Copy link
Contributor

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

} document_body_t;

typedef struct document_body_header {
uint32_t entrypoint_block_index;
Copy link
Contributor

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?

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants