Skip to content

Disregard stack, use register machine with infinite registers #5

Open
@vendethiel

Description

@vendethiel

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions