-
Notifications
You must be signed in to change notification settings - Fork 13
feat: enable struct variable declarations #153
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
base: main
Are you sure you want to change the base?
Conversation
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} src/irx/system.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} tests/test_struct_type.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} |
a864bf6 to
7b55be5
Compare
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} src/irx/system.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} tests/test_struct_type.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} |
7b55be5 to
12daeb6
Compare
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} src/irx/system.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} tests/test_struct_type.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for declaring variables with struct types, implementing Phase 2 of struct support. It introduces a new StructType class for type references and extends the LLVM IR visitor to handle struct variable declarations with stack allocation and zero-initialization.
- Introduces
StructTypeclass as a type reference mechanism for previously defined structs - Extends
visit(VariableDeclaration)to detect and handle struct types with allocation and zero-initialization - Adds comprehensive test coverage for struct variables, undefined struct errors, and unsupported value initialization
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/irx/system.py | Adds StructType class for referencing previously defined structs |
| src/irx/builders/llvmliteir.py | Extends visitor to handle struct variable declarations with stack allocation and zero-initialization; adds struct_types dictionary tracking |
| tests/test_struct_type.py | Adds three test cases covering basic struct variable declaration, undefined struct error handling, and value initialization error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add StructType to reference defined structs in variable declarations. Variables are allocated on stack and zero-initialized.
12daeb6 to
f9b4c9a
Compare
OSL ChatGPT ReviewerNOTE: This is generated by an AI program, so some comments may not make sense. src/irx/builders/llvmliteir.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} src/irx/system.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} tests/test_struct_type.pyChatGPT was not able to review the file. Error: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.', 'type': 'insufficient_quota', 'param': None, 'code': 'insufficient_quota'}} |
|
@omsherikar , the CI/CC seems to fail , please look into it |
@yuvimittal CI is failing because the tests create StructDefStmt nodes to define structs, but the visitor method for StructDefStmt is missing, which is in pr #150 |
Then please add these changes to PR #150 and push them there. Let’s keep this as a single PR rather than creating multiple ones. |
|
@omsherikar , i am converting this to draft so we know alright!? |
Pull Request description
This PR adds support for declaring variables with struct types by introducing
StructType, a type reference that resolves to previously defined structs. This enables Phase 2 of struct support, allowing struct variables to be declared and allocated on the stack with zero-initialization.Changes:
StructTypeclass insystem.pythat inherits fromastx.DataTypevisit(VariableDeclaration)to detect and handleStructTypeinstancesir_builder.alloca()and zero-initializedNote: This PR depends on Phase 1 (StructDefStmt implementation) being merged first. The struct tests will fail until
visit(astx.StructDefStmt)is available in the codebase.How to test these changes
Run the struct type tests
pytest tests/test_struct_type.py -v
Run all tests (struct tests will fail if Phase 1 not merged)
pytest tests/ -v
**Example usage:**on
from irx.system import StructType
import astx
Define a struct
struct_def = astx.StructDefStmt(
name="Point",
attributes=[
astx.VariableDeclaration("x", astx.Int32()),
astx.VariableDeclaration("y", astx.Int32()),
],
)
Declare a struct variable
struct_var = astx.VariableDeclaration(
name="p",
type_=StructType(struct_name="Point"),
)## Pull Request checklists
This PR is a:
About this PR:
Author's checklist:
Additional information
Implementation details:
Dependencies:
self.struct_typesdictionary populated byvisit(astx.StructDefStmt)Future work: