Skip to content

Rewrite integer and long compound assignments to match Java overflow behavior.#2784

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

Rewrite integer and long compound assignments to match Java overflow behavior.#2784
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_936897994

Conversation

@copybara-service

Copy link
Copy Markdown

Rewrite integer and long compound assignments to match Java overflow behavior.

Adds inline functions in J2ObjC_source.h for +=, *=, and -= operations on byte, char, short, int and long types. These functions use unsigned arithmetic for the operations to ensure Java's two's complement overflow behavior is preserved, then cast the result back to the signed type.

The OperatorRewriter is updated to rewrite compound assignmentsto use these new inline functions. This ensures that expressions like i += j or l *= k in Java are translated to Objective-C with the correct overflow semantics.

…behavior.

Adds inline functions in J2ObjC_source.h for `+=`, `*=`, and `-=` operations on byte, char, short, int and long types. These functions use unsigned arithmetic for the operations to ensure Java's two's complement overflow behavior is preserved, then cast the result back to the signed type.

The OperatorRewriter is updated to rewrite compound assignmentsto use these new inline functions. This ensures that expressions like `i += j` or `l *= k` in Java are translated to Objective-C with the correct overflow semantics.

PiperOrigin-RevId: 936897994
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