eddic 1.2.0 - Single inheritance, copy construction

I'm happy to release the version 1.2.0 of the EDDI Compiler (eddic).

This new version introduces several major changes to the language.

First of all, structures can now inherits from another structure. When it is done, the structure can use the members of the parent class. Below is an example of single inheritance in EDDI:

struct A {
    float a;

    void init_a(){
        a = 55.2;
    }

    void test_a(){
        a += 1.1;
    }
}

struct B extends A {
    char a;

    void init_b(){
        a = 'B';
        init_a();
    }

    void test_b(){
        test_a();
    }
}

For now, the support remains basic, but it will be improved over time. I will probably add support for virtual functions in the future.

Another major improvement to the language is that variable of a custom type can now be assignment, resulting in a call to the copy constructor. If no copy constructor is defined in a structure, it is automatically generated by the compiler. Another improvement to structures is that structures can now contains arrays. Moreover, the members of a structure (fields, constructors, functions, ...) can now be present in any order.

A major change has been made to pointers. The conversions from variables to pointers is no more implicit, it is necessary to use the new & operator to take the address of a variable. I found that this implicit conversions was not really making any sense.

A function can now return a structure by value. And, member functions can be called from any valid left value. For instance:

array[5].function(5).function(9);

is now valid code.

Finally, the switch construct can be used with strings too. This uses the str_equals functions to test which case is valid.

There are no big changes in the optimization engine. A new optimization pass has been added performing loop unrolling for loop with known iteration count. The pointer propagation has been fixed to handle pointers on structures resulting in much better code for several samples. The last improvement here is that conditions can be propagated into branches when necessary.

The loop analysis has been improved to directly calculate the number of iterations of each loop and store this result. The list of induction variables is only calculated once now.

The code generation has been slightly improved by saving fewer registers when calling another function.

Finally, there are also some internal changes. The template instantiation depth limit can now configured. Before, infinite template recursion would just fail. The time spent in each optimization can now be computed with the new --timing option. There have been great improvements on the side of the Abstract Syntax Tree. A good part of the expression grammar has been rewritten. With these changes, the grammar is much more powerful than before.

Don't hesitate to comment or to contact me if you have any suggestion (or other) about this release or for the future versions of eddic.

I'd also like to thank TyRoXx who has made some improvements in the assembly generation module.

Future Work

The next version of the EDDI compiler (eddic) will be the version 1.2.1. This version will specifically focus on two points. First the usage of strings will be improved with a string class adding features to literal string. The second point will be the performances of the compiler. At this point, the optimization engine is clearly too slow. I will try to make it faster. The list of issues is available on Github.

Download

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

The version is available in the v1.2.0 tag available in the GitHub or directly in the master branch.

Related articles

  • EDDI Compiler 1.1.3 - Templates
  • eddic 1.2.1 - string, concatenation and vector
  • eddic 1.2.3 - Better data-flow analysis
  • EDDI Compiler 1.1.0 - Member functions
  • EDDI Compiler 1.0.1 - Pointers and better struct support
  • EDDI Compiler 1.0 - Structures and Global Optimizations
  • Comments

    Comments powered by Disqus