HybriC rewritten in pure C

I have rewritten HybriC compiler in pure C (so it would be possible to integrate parts of it into virtual machine itself, probably, since virtual machine is written in C).

Along with that I changed how it generates code (it was an obvious change). Now it creates a code tree (which is pretty much one of cases of general syntax tree), then optimizes it, and writes down.

This is a bit different to alternate approach – generate code first, then optimize known patterns. But I think I’ll add both ways later.

To illustrate, here’s how it would compile expression R0 = (1 - R1*R2) + (R0 - R0):
scheme

Some leaves would be cut off, and here’s roughly the code it should generate:
mov R3,R1;
mul R3,R2;
mov R4,1;
sub R4,R3;
mov R0,R4;

2 Responses to “HybriC rewritten in pure C”


Leave a Reply