Skip to content

PyLaurel Class Support#480

Open
andrewmwells-amazon wants to merge 26 commits intomainfrom
feature/class-support
Open

PyLaurel Class Support#480
andrewmwells-amazon wants to merge 26 commits intomainfrom
feature/class-support

Conversation

@andrewmwells-amazon
Copy link
Contributor

@andrewmwells-amazon andrewmwells-amazon commented Feb 24, 2026

Add Basic Class Declaration Support to Python → Laurel Translation

Implements foundational support for Python class declarations in the Python → Laurel → Core translation pipeline. This PR focuses on getting the basic class infrastructure working, with field initialization and access deferred to future work.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

andrewmwells-amazon and others added 4 commits February 24, 2026 19:37
- Add CompositeType tracking to TranslationContext
- Add currentClassName for tracking context during method translation
- Update translateType to handle UserDefined types (classes)
- Implement field access via Attribute expressions (self.field)
- Handle constructor calls: Class() -> new Class + __init__()
- Add helper functions: extractClassFields, translateMethod, translateClass
- Implement two-pass translation: collect classes first, then translate
- Add classes to program's type definitions

Test: test_class_decl.py now passes (7 assertions)
Handles: self.field = value and obj.field = value

Previously only AnnAssign supported field assignments.
Now Assign statements can target Attribute expressions (field access).

Impact: +4 benchmarks now translate (21→25, 42%→50%)
@ssomayyajula ssomayyajula self-requested a review February 24, 2026 19:58
Copy link
Contributor

@ssomayyajula ssomayyajula left a comment

Choose a reason for hiding this comment

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

Almost everything looks standard to me, but what is this issue with "hoisting" of holes that keeps occurring for? Should that be a separate pass?

oyendrila-dobe
oyendrila-dobe previously approved these changes Feb 25, 2026
Copy link

@oyendrila-dobe oyendrila-dobe left a comment

Choose a reason for hiding this comment

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

LGTM.
Can we add a note to credit kiro-cli for the all the code changes related to handling of class declaration?

@andrewmwells-amazon andrewmwells-amazon marked this pull request as ready for review February 26, 2026 21:46
@andrewmwells-amazon andrewmwells-amazon requested a review from a team February 26, 2026 21:46
aqjune-aws
aqjune-aws previously approved these changes Feb 27, 2026
shigoel
shigoel previously approved these changes Feb 27, 2026
@thanhnguyen-aws thanhnguyen-aws added this pull request to the merge queue Feb 27, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
@thanhnguyen-aws thanhnguyen-aws added this pull request to the merge queue Feb 27, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
@thanhnguyen-aws thanhnguyen-aws added this pull request to the merge queue Feb 27, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
@aqjune-aws aqjune-aws added this pull request to the merge queue Feb 27, 2026
@oyendrila-dobe oyendrila-dobe removed this pull request from the merge queue due to a manual request Feb 27, 2026
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.

7 participants