Skip to content

Fix underlying type of enums #38

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

Merged
merged 3 commits into from
Jun 7, 2018
Merged

Conversation

kornilova203
Copy link
Member

Issue #12

@kornilova203 kornilova203 force-pushed the fix-underlying-type-of-enums branch from a22c2fa to 3a95e9c Compare June 6, 2018 12:51
ir/Enum.cpp Outdated
s << ".toULong" << "\n";
} else {
llvm::errs() << "Enum type is unsupported: " << e.type << "\n";
llvm::errs().flush();
Copy link
Member Author

Choose a reason for hiding this comment

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

This should not happen since uint64_t is unsigned long int

@kornilova203 kornilova203 force-pushed the fix-underlying-type-of-enums branch from 6a05c15 to de446f0 Compare June 6, 2018 13:36
@kornilova203
Copy link
Member Author

@jonas, I added types to enumerators, they used to be regular Scala types, now they are native.CUnsignedInt or native.CUnsignedLong, see tests/samples/Enum.scala

@kornilova203 kornilova203 force-pushed the fix-underlying-type-of-enums branch from de446f0 to afc18ee Compare June 6, 2018 13:58
@kornilova203 kornilova203 force-pushed the fix-underlying-type-of-enums branch from afc18ee to 728c49b Compare June 6, 2018 13:58

enum bigValues {
A = 10000000000, // does not fit into int
B = 1
Copy link
Member

Choose a reason for hiding this comment

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

How about also adding a negative value?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good point, I totally forgot about negative numbers

final val enum_days_THURSDAY: enum_days = 3.toUInt
final val enum_days_FRIDAY: enum_days = 4.toUInt
final val enum_days_SATURDAY: enum_days = 5.toUInt
final val enum_days_SUNDAY: enum_days = 6.toUInt
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@jonas jonas left a comment

Choose a reason for hiding this comment

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

LGTM

@kornilova203 kornilova203 merged commit 86d9bb3 into master Jun 7, 2018
@kornilova203 kornilova203 deleted the fix-underlying-type-of-enums branch June 8, 2018 09:08
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