Skip to main content

EDDI Compiler 1.1.0 - Member functions

The version 1.1.0 of the EDDI Compiler (eddic) is available. It took much less time to implement that version than I thought.

The main change to the language is the support of member functions. Each structure can now declare some functions. Functions can be called in each structure object. Here is an example of what can be done with that feature in EDDI:

struct Counter {
    int value;

    void increment(){
        this.value = this.value + 1;

    void add(int number){
        this.value = this.value + number;

    void add(int n1, int n2){
        this.value = this.value + n1;
        this.value = this.value + n2;

void main(){
    Counter counter;


    counter.add(11, 69);

The this pointer is available in each member function. The pointer is passed on the stack just like any other parameter.

Another improvement is the support of the ternary operator:

void main(){
    int a = 5 > 2 ? 44 : 66;

The inliner has been improved to support inlining member functions and functions with pointer parameters. The parameter allocation in register is only done starting at O1.

The peephole optimizer has also been improved. Some stacks operations optimization are performed and some unnecessary copies of parameter register are removed.

Finally, the assembly generation has been improved to not use stack frames starting at O2. When this optimization is enabled, the local variables are addressed using stack pointers instead of the base pointer that is not used anymore. This optimization reduces the overhead of function calls.

Future work

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


You can find the compiler sources on the Github repository:

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


Comments powered by Disqus