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

Refactor compiler #38

Open
kovasb opened this issue Jan 17, 2017 · 0 comments
Open

Refactor compiler #38

kovasb opened this issue Jan 17, 2017 · 0 comments

Comments

@kovasb
Copy link
Owner

kovasb commented Jan 17, 2017

The compiler is too complicated for people to contribute / fix their bug.

A - Document how stuff works
B - Add compiler tests for key transformations
C - Refactor
D - Profit

How Stuff Works

User generates gamma ast. This is a tree.
Compiler gets tree.
First: flatten-ast . This turns tree into a graph; we call this the 'db'.
Right now all transforms operate on this graphlike 'db'. This causes complexity. ToFix.

Transformation 1: bubble-terms.
This generates information needed for detecting common subexpressions.
For each subexpression in the db, we traverse its parents up the tree. For each parent, we associate the start node to its meta info (:shared )
Specifically, we add it to a hashmap of { start-node times-seen }
Every time a node equivalent to start-node passes though a parent on the way up, we increment this count.
This principle is extended to deal with conditionals. If a node is scoped within an 'if' it will not necessarily evaluate. However we wish to propagate this information. Therefor node counts

[todo more description]

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