rune icon indicating copy to clipboard operation
rune copied to clipboard

Introduce a HIR (help wanted)

Open udoprog opened this issue 3 years ago • 0 comments

This is a tracking issue for introducing a HIR for Rune.

This is currently done in the hir branch.

Why a HIR?

The intention here is to further decouple AST from code generation which should make it feasible to perform internal code generation to simplify the compiler.

As an example, all of these loop-style constructs currently have their own dedicated representation being processed by the assembler:

While loop:

while <cond> <block>

Unconditional loop:

loop <block>

For loop:

for <pat> in <expr> <block>

With a HIR all of these could be "desugared" into the same loop construct rather than being fed into the assembler as distinct constructs, so the for loop would be desugared into something like:

let mut it = <expr>;

loop {
    let <pat> = match it.next() {
        Some(value) => value,
        None => break,
    };

    <block>
}

This also has benefits for constant evaluation, since a HIR can be designed to be simpler to evaluate than directly evaluating AST.

I want to help out!

Great! This is an excellent issue that will improve the compiler for Rune and get you deep into its architecture. You couldn't have made a better choice!

To contribute, indicate what you want to do in this thread to coordinate, once you've done something that you want reviewed set up a pull request against the hir branch.

udoprog avatar Jun 25 '22 20:06 udoprog