EDDI Compiler 1.0.1 - Pointers and better struct support

The version 1.0.1 of the EDDI Compiler (eddic) is now available.

The language itself has been updated to support pointers. For now, this support is quite basic, but it allows to pass any type of the language by pointer to a function. No arithmetic is permitted on pointers, only dereferencing is allowed. The following sample shows how pointers are used in the language:

struct A {
    int a;
    string b;
    float c;
}

void main(){
    A a;

    a.a = 44;
    a.b = "44";
    a.c = 44f;

    test(a); 
    print(a.a);
    print("|");
}

void test(A* a){
    A* b = a;

    a.a = 55;

    print(a.a);
    print("|");

    b.a = 66;
    b.b = "66";
    b.c = 66f;

    print(a.a);
    print("|");
    print(b.a);
    print("|");
}

This sample is not very useful, but it shows the usage of pointers well enough.

Another improvement to the language is that it supports now nested struct. It means that a member of a struct can be a struct itself.

That's it for the language improvements. On the side of the compiler itself, I've improved the error reporting for structs. For example, the compiler display a clear error when a struct is recursively nested. The peephole optimizer has been improved a bit with new optimization, but it still rather simple. The optimization engine is now able to optimize functions in parallel. The improvement is not quite large, but that can be useful if there are a lot of functions. I've also improved a lot the Abstract Syntax Tree representation of assignments to unify variable, array and struct assignments in one Node with the notion of LeftValue.

Finally, the tests have also been improved. New tests have been added and helped me find new bugs. Moreover, the tests are now made on each optimization levels for each test case. There was some issue with smallest optimization level.

Future work

The next version of the EDDI Compiler will be the version 1.0.2.

This version will adds support for returning a pointer from a function. Moreover, it will also adds support for pointers inside of struct. The last change to the language will be that you will be able to declare array of pointers and array of structure.

The peephole optimizer will perform more powerful optimization. At least, I will add an optimization to remove assignments to registers that are not used and use less registers. That will perhaps imply to add support for basic blocks in the LTAC Language.

I will also add a powerful dead-code optimization to the Optimization Engine. This will replace the RemoveAssign and RemoveMultipleAssign pass of the engine, being more powerful.

As ever, I'm open to any idea you could have about this project :)

Download

You can find the compiler sources on the Github repository: https://github.com/wichtounet/eddic

The exact version I refer to is the v1.0.1 available in the GitHub tags or directly as the release branch.

Related articles

  • EDDI Compiler 1.0.2 – Better pointer support and Dead-Code Elimination
  • EDDI Compiler 1.0 - Structures and Global Optimizations
  • EDDI Compiler 1.1.3 - Templates
  • EDDI Compiler 1.1.0 - Member functions
  • EDDI Compiler 1.0.3 - Inlining and register allocation
  • eddic 1.2.0 - Single inheritance, copy construction
  • Comments

    Comments powered by Disqus