Skip to content

native: add support for enums of different types#23786

Merged
spytheman merged 4 commits into
vlang:masterfrom
Eliyaan:enum-sizes
Feb 22, 2025
Merged

native: add support for enums of different types#23786
spytheman merged 4 commits into
vlang:masterfrom
Eliyaan:enum-sizes

Conversation

@Eliyaan

@Eliyaan Eliyaan commented Feb 22, 2025

Copy link
Copy Markdown
Member

Add support for enums with a user-chosen type like enum MyEnum as u8
Instead of duplicating functions for u64 and i64, use a sumtype
Add tests for enums of different types

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22197

Comment thread vlib/v/gen/native/amd64.v
c.g.write8(i32(0x45) + far_var_offset)
// Generate N in `[rbp-N]`
if is_far_var {
c.g.write32(i32((0xffffffff - i64(n) + 1) % 0x100000000))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, why % 0x100000000, instead of masking with & (0x100000000 - 1) ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not touch this part of the code as I dont know much about machine code addressing

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, but in general, please keep in mind, that it is better to split refactoring PRs (especially ones that affect a lot of code), from ones that add functional changes/features/bugfixes.

Mixing too many things in the same one, makes many things harder than they could be otherwise, and increases the chances of conflicts with other PRs.

@spytheman spytheman merged commit 5376a55 into vlang:master Feb 22, 2025
@Eliyaan

Eliyaan commented Feb 22, 2025

Copy link
Copy Markdown
Member Author

Okay I'll keep that in mind.

@Eliyaan Eliyaan deleted the enum-sizes branch February 22, 2025 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants