zom-lang / zom

Zom is a Ahead Of Time compiled system programming language.
Other
4 stars 2 forks source link

Make an AOT #27

Closed Larsouille25 closed 1 year ago

Larsouille25 commented 1 year ago

I'm not very happy with the current, project, I realize that Mona is more a Ahead Of Time compiled programming language than a Just In Time compiled one. So here is the steps to modify Mona to be a AOT compiled one :

Larsouille25 commented 1 year ago

When, this issue is closed and the branch 27-aot merged. Re-enable the CI for mona_fe and mona_common.

Larsouille25 commented 1 year ago

That works ! I'm not able to use the output in an example with c++, but with objdump, we can dissassemble output.o and we found ->

output.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <foo>:
   0:   b8 7b 00 00 00          mov    $0x7b,%eax
   5:   c3                      ret

So the function foo return 0x7b so 123

Larsouille25 commented 1 year ago

The error is ->

main.cpp:12:27: error: no matching function for call to 'foo'
    std::cout << "foo" << foo(3.0, 4.0) << std::endl;
                          ^~~
main.cpp:8:9: note: candidate function not viable: requires 0 arguments, but 2 were provided
    int foo();
        ^
1 error generated.

I think it could be the mangling of function name

Larsouille25 commented 1 year ago

This source code

func main()
    1

After compiling and linking with gcc output.o and execute a.out that works, no error, nothing but it's already that