refactor(core): improve string support#342
Open
Guikingone wants to merge 1 commit into
Open
Conversation
…rg unboxing Three related string-builtin fixes. wordwrap: rewrite __rt_wordwrap on ARM64 and x86_64 to PHP's word-aware algorithm (break at the last space at/after the width; an over-long word stays intact unless cut_long_words is set; existing newlines reset the line length) and plumb the cut_long_words flag through codegen (x6 ARM64 / r9 x86_64). It was previously a fixed-width char-wrapper with the cut flag never passed to the runtime. sprintf/printf: __rt_sprintf dispatches on the conversion specifier character (f/e/g→float, s→string, else→int), not on the pushed record tag, so a Mixed or cross-type argument was misread (Mixed→0, int under %s→empty, string under %d→pointer). Add a shared format_args::emit_format_and_call (used by both sprintf and printf) that parses the literal format and coerces each argument to its specifier's type before pushing a matching record. A string under an integer specifier is cast with __rt_str_to_int locally in this path rather than widening the shared coerce_result_to_type (other call sites gate coercion on it). string builtins: unbox Mixed/Union arguments to the single- and multi-argument string builtins through the shared super::args::emit_string_arg helper, so a Mixed operand is cast via __rt_mixed_cast_string instead of leaving a boxed cell with stale string registers. Adds regression tests across formatting/encoding/transform; output matches PHP.
0f7d057 to
9ba48a2
Compare
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.
No description provided.