Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] [PoC] lib.enum: forward property accesses from enum view to base enum#1426

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
whitequark wants to merge1 commit intoamaranth-lang:main
base:main
Choose a base branch
Loading
fromwhitequark:enum-predicates-proof-of-concept

Conversation

@whitequark
Copy link
Member

@whitequarkwhitequark commentedJun 27, 2024
edited
Loading

Proof of concept PR for#1419.

Can be tested with:

fromamaranthimport*fromamaranth.libimportenumclassMyEnum(enum.Enum,shape=3):GetX1=0GetX2=1GetX4=2PutX1=3PutX2=4PutX4=5@propertydefis_get(self):returnselfin [MyEnum.GetX1,MyEnum.GetX2,MyEnum.GetX4]@propertydefis_put(self):returnselfin [MyEnum.PutX1,MyEnum.PutX2,MyEnum.PutX4]sig=Signal(MyEnum)print(sig.is_get)print(sig.is_put)print(sig.x)

This returns:

(proxy (array [True, True, True, False, False, False]) (sig sig))(proxy (array [False, False, False, True, True, True]) (sig sig))Traceback (most recent call last):  File "/home/whitequark/Projects/amaranth/xenum.py", line 25, in <module>    print(sig.x)          ^^^^^  File "/home/whitequark/Projects/amaranth/amaranth/lib/enum.py", line 317, in __getattr__    raise AttributeError(f"{self!r} has no attribute {name!r}")AttributeError: EnumView(MyEnum, (sig sig)) has no attribute 'x'

nelgau reacted with heart emoji
@whitequarkwhitequark marked this pull request as draftJune 27, 2024 15:04
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@whitequark

[8]ページ先頭

©2009-2025 Movatter.jp