Skip to content

Emulate Java integer overflow behavior in Objective-C.#2782

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_936861259
Open

Emulate Java integer overflow behavior in Objective-C.#2782
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_936861259

Conversation

@copybara-service

Copy link
Copy Markdown

Emulate Java integer overflow behavior in Objective-C.

This change introduces helper functions (JreIntAdd, JreIntSub, JreIntMul, etc.) that use unsigned arithmetic to ensure that integer and long addition, subtraction, and multiplication operations in j2objc-translated code wrap around on overflow, matching Java's specification. The translator's OperatorRewriter is updated to use these new helper functions for the +, -, and * operators on int and long types. New tests are added to IntegerTest to verify the overflow wraparound.

This change introduces helper functions (JreIntAdd, JreIntSub, JreIntMul, etc.) that use unsigned arithmetic to ensure that integer and long addition, subtraction, and multiplication operations in j2objc-translated code wrap around on overflow, matching Java's specification. The translator's OperatorRewriter is updated to use these new helper functions for the +, -, and * operators on int and long types. New tests are added to IntegerTest to verify the overflow wraparound.

PiperOrigin-RevId: 936861259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants