Skip to content

Refactor compiler #38

Description

@kovasb

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions