Repository navigation
core: Preserve endian qualifiers on template arguments - #259
Open
AkiSakurai wants to merge 2 commits into
Open
AkiSakurai wants to merge 2 commits into
AkiSakurai wants to merge 2 commits into
Conversation
Copy m_endian, m_reference, and m_templateParameterIndex when evaluating or cloning ASTNodeTypeApplication so be/le on template arguments survives nested binding.
Example (test_data starts with PNG signature 89 50 4E 47):
struct Box<T> { T v; };
Box<be u32> b @ 0;
Before: b.v read as 0x474E5089 (le) — 'be' dropped during evaluate()
After: b.v read as 0x89504E47 (be) — template argument endian preserved
Adds TemplateEndian test.
Co-authored-by: opencode <opencode@opencode.ai>
setEndian() refuses to pin patterns in the heap, pattern-local, and
instantiation sections, but getEndian() still fell back to the ambient
default for them. An unset endian therefore answered whatever the
evaluator's current default happened to be, so a value written under
one default could be read back under another: a template parameter
initialized inside a 'be' instantiation but used after the scope
restored the little-endian default, or a heap variable read while a
'be' instantiation was being created.
Example (test_data starts with PNG signature 89 50 4E 47):
struct Test<auto t> { u32 a = t; };
be Test<5> test;
Before: test.t printed 6646139978924579364519035301401722880 (5 << 120)
After: test.t prints 5 — unpinned non-file patterns now round-trip
with native endian regardless of ambient default changes
auto g = 16909060;
struct Q<auto t> { u32 a = g; };
be Q<5> q;
Before: q.a printed 0 (g's little-endian bytes decoded as big endian)
After: q.a prints 16909060
Extends the TemplateEndian test with non-type template parameters under
be/le (placed and local) and a heap variable read under 'be'.
fix: WerWolv#119
Co-authored-by: opencode <opencode@opencode.ai>
Contributor
Author
|
I found a regression that causes issue #119, so I added a commit to fix it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Copy m_endian, m_reference, and m_templateParameterIndex when evaluating or cloning ASTNodeTypeApplication so be/le on template arguments survives nested binding.
Example (test_data starts with PNG signature 89 50 4E 47):
Before: b.v read as 0x474E5089 (le) — 'be' dropped during evaluate()
After: b.v read as 0x89504E47 (be) — template argument endian preserved
Adds TemplateEndian test.