Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WASM_X64: Support local variables #1361

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 7 commits into from
Dec 15, 2022

Conversation

ubaidsk
Copy link
Collaborator

@ubaidsk ubaidsk commented Dec 15, 2022

This PR adds support for local variables in the wasm_x64 backend.

Examples:

$ cat examples/expr2.py 
def main0():
    x: i32
    x = (2+3)*5
    y: i32
    z: i32
    y = 14
    z = 2
    print(x + y * z)

main0()
$ lpython examples/expr2.py --backend wasm_x64 -o tmp
Call to print_i32() will be printed as exit code
Call to flush_buf() is not yet supported
$ ./tmp
$ echo $?
53
$ cat examples/expr2.py 
def sqr(x: i32) -> i32:
    return x * x

def main0():
    pi: i32 = 3
    r: i32 = 5
    area: i32
    area = pi * sqr(r)
    print(area)

main0()
$ lpython examples/expr2.py --backend wasm_x64 -o tmp
Call to print_i32() will be printed as exit code
Call to flush_buf() is not yet supported
$ ./tmp
$ echo $?
75

@ubaidsk
Copy link
Collaborator Author

ubaidsk commented Dec 15, 2022

The bottom two commits are part of #1360. The rest of the commits are part of this PR. I will rebase this PR after merging of #1360.

@ubaidsk
Copy link
Collaborator Author

ubaidsk commented Dec 15, 2022

This is ready. Please possibly review and please share feedback.

@ubaidsk ubaidsk requested a review from certik December 15, 2022 02:50
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

I think this looks great.

@certik certik merged commit d36a853 into lcompilers:main Dec 15, 2022
@ubaidsk ubaidsk deleted the wasm_x64_local_get_set branch December 16, 2022 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants