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

Disregard stack, use register machine with infinite registers #5

Open
vendethiel opened this issue Aug 25, 2020 · 0 comments
Open

Disregard stack, use register machine with infinite registers #5

vendethiel opened this issue Aug 25, 2020 · 0 comments

Comments

@vendethiel
Copy link
Member

compileFn returns

data VarIdx = Local Int | Temp Int | NoRes
compileFn :: ... -> (VarIdx, [Instructions])

instead of the whole stack thing, when encountering a variable decl, introduce a new Local, and when compiling an expression, a new Temp.
That probably means a State that keeps:

  • Local mapping Map String Local (local name => var idx).
    Without shadowing, otherwise need to find a different way)
  • The last Temp seen (and a function newTemp that increments the one in the State and returns it).
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

No branches or pull requests

1 participant