Skip to content

C: Add printing support for Lists #1405

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 8 commits into from
Jan 7, 2023

Conversation

Smit-create
Copy link
Collaborator

No description provided.

@Smit-create Smit-create added the c Label for C language related changes label Jan 7, 2023
@Smit-create Smit-create marked this pull request as ready for review January 7, 2023 06:54
Copy link
Collaborator

@czgdp1807 czgdp1807 left a comment

Choose a reason for hiding this comment

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

Can we just call the following pass in C backend instead of implementing printing of list in C backend again? Let me know if calling the pass will work.

void pass_replace_print_list(

@Smit-create
Copy link
Collaborator Author

The pass is not that robust, see with the current main branch the following fails in the LLVM backend:

def test_print_list():
    a: list[str] = ["ab", "abc", "abcd"]

    print(a) # works
    print(a, a) # fails

test_print_list()

Also, that pass seems to be only working for single argument list type, not with nested tuple, see:

def test_print_list():
    a: list[tuple[i32, i32]] = [(1,2), (3, 4), (5, 6)]

    print(a) # fails

test_print_list()

That will require much work on the pass too.

Moreover, C, at present, doesn't use any passes and already has a design that will need slight modifications to make all this work.

I will fix those issues with the pass in a new PR soon to make it work for LLVM.

@czgdp1807
Copy link
Collaborator

Associated issue, #1129. But anyways we still need the ASR pass to work for lists.

@Smit-create Smit-create merged commit f05a4d3 into lcompilers:main Jan 7, 2023
@Smit-create Smit-create deleted the print_list_c branch January 7, 2023 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c Label for C language related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants