-
-
Notifications
You must be signed in to change notification settings - Fork 629
Expand ECMAScript implementation: Add integer conversions and fundamental operations #12687
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
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
…perations Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
@copilot please continue |
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
I've continued expanding the ECMAScript implementation by adding 5 more fundamental operations: New Integer Conversions:
Fundamental Operations:
All 32 tests pass, bringing the total from 23 to 32 test functions. These operations are essential building blocks for JavaScript tooling and complete the core integer conversion family used throughout the ECMAScript specification. |
CodSpeed Instrumentation Performance ReportMerging #12687 will not alter performanceComparing Summary
Footnotes |
This PR significantly expands the
oxc_ecmascript
crate by implementing missing ECMAScript abstract operations essential for JavaScript tooling.What's Added
Integer Conversion Operations (9 total):
ToUint32
,ToUint16
- Unsigned integer conversions for bitwise operationsToInt8
,ToInt16
- Signed integer conversions completing the familyToUint8
,ToUint8Clamp
- 8-bit conversions for typed arrays (ToUint8Clamp uses banker's rounding)ToLength
- Array/string length conversion with MAX_SAFE_INTEGER clampingMathematical Operations:
MathAbs
,MathFloor
,MathCeil
,MathRound
- Core mathematical functionsMathMax
,MathMin
- Comparison operations with helper functionsString Operations:
StringSlice
- String.prototype.slice with Unicode supportStringIncludes
- String.prototype.includes with position parameterStringStartsWith
,StringEndsWith
- String matching operationsStringRepeat
- String.prototype.repeat with error handlingStringTrim
,StringTrimStart
,StringTrimEnd
- Whitespace trimmingFundamental Operations:
SameValue
- Strict equality (distinguishes +0/-0, treats NaN as equal to itself)SameValueZero
- Like SameValue but treats +0 and -0 as equalImplementation Details
All operations follow the ECMAScript specification precisely:
This brings
oxc_ecmascript
much closer to a complete implementation of core ECMAScript abstract operations, making it significantly more useful for JavaScript tooling that needs spec-compliant behavior.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.