Skip to content
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

Allow cursor to be moved forwards #17

Merged
merged 1 commit into from
Nov 6, 2024
Merged

Conversation

OFFTKP
Copy link
Contributor

@OFFTKP OFFTKP commented Nov 1, 2024

As mentioned in #13, allows for backpatching instructions then moving back to the previous position.

Example usage:

ptrdiff_t cursor = as.GetCodeBuffer().GetCursorOffset();
as.RewindBuffer(jump.location);
Emitter::EmitJump(*this, &block_map[jump.target]);
as.AdvanceBuffer(cursor);

Asserts changed in GetOffsetPointer to allow for emitting branches to Labels that point forwards in the buffer.

Feel free to suggest changes if this implementation is not optimal.

Copy link
Owner

@lioncash lioncash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, thanks for the patch!

@lioncash lioncash merged commit ce1e82f into lioncash:main Nov 6, 2024
4 checks passed
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.

2 participants