Skip to content
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

ASR -> CPython: Add list method visitors #2694

Merged
merged 6 commits into from
May 11, 2024

Conversation

kmr-srbh
Copy link
Contributor

@kmr-srbh kmr-srbh commented May 10, 2024

from lpython import i32, f64

# global scope
my_first_list: list[i32] = [1, 2, 3, 4, 5]
print(my_first_list)

my_first_list.append(4)
my_first_list.remove(2)
print(my_first_list.count(4))
my_first_list.insert(0, 1)
my_first_list.clear()

# local scope
def f():
    my_first_list: list[i32] = [1, 2, 3, 4, 5]
    print(my_first_list)

    my_first_list.append(4)
    my_first_list.remove(2)
    print(my_first_list.count(4))
    my_first_list.insert(0, 1)
    my_first_list.clear()


f()
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py --show-python
def __main__global_stmts():
    my_first_list = [1, 2, 3, 4, 5]
    print(my_first_list)
    my_first_list.append(4)
    my_first_list.remove(2)
    print(my_first_list.count(4))
    my_first_list.insert(0, 1)
    my_first_list.clear()
    f()
def f():
    my_first_list: list[i32]
    my_first_list = [1, 2, 3, 4, 5]
    print(my_first_list)
    my_first_list.append(4)
    my_first_list.remove(2)
    print(my_first_list.count(4))
    my_first_list.insert(0, 1)
    my_first_list.clear()

@kmr-srbh
Copy link
Contributor Author

@Shaikh-Ubaid could you please look into the anomaly occurring in the generated code when a function call is present inside a function, as in, print(my_first_list.count(4))?

@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as draft May 11, 2024 05:37
@kmr-srbh kmr-srbh marked this pull request as ready for review May 11, 2024 16:14
Copy link
Collaborator

@Shaikh-Ubaid Shaikh-Ubaid left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@Shaikh-Ubaid Shaikh-Ubaid merged commit 5452ed1 into lcompilers:main May 11, 2024
14 checks passed
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.

2 participants