core: add support for class attributes (issue-102) #425
No reviewers
Labels
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#425
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue-102"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The main changes are as follows:
Class Definition
Created new section for class attributes
Each class retains one copy of immutable attributes
Core
Added support for processing class attributes and their code generation
nac3artiq
Allowed class attributes of classes without __init__ function to be accessed by bypassing the initialization check
Please run the pre-commit hooks (i.e.
cargo clippy
andcargo fmt
) on each commit so that theapply cargo fmt
commit can be dropped.@ -1475,3 +1552,3 @@
class_fields_def.drain(..);
class_fields_def.extend(new_child_fields);
class_attribute_def.drain(..);
class_attribute_def.clear()
You can also change the use above for
class_fields_def
.5bc76583ef
to45708aadda
Force pushed to update commit history. Also replaced
.drain(..)
with.clear()
in nac3core/src/toplevel/composer.rs@ -0,0 +4,4 @@
@nac3
class XXX:
ATTR1: KernelInvariant[int32] = 2
Nit: Does Python use all caps in this way?
I was using the example given in #102, but I see your point. I will update the file and while I am at it, refactor nac3core/composer to avoid code duplication
45708aadda
to43991b150b
43991b150b
toad1b4f1b9b
Revised.
@derppening OK to merge this?
Yes, I think this is ready to be merged.