Saturday, February 24, 2007

Hyper compiler 0.3.33 released

I have released a new version of the compiler again, we're at 0.3.33 right now. The version number is actually increasing less fast than before I did any releases. The first private release was 0.3.26, the first public release was 0.3.29, so this is the fifth release I have done. Before I started releasing versions I also incremented the version number, but this was a lot faster than it is now. For the same amount of changes that are now in one new release, I would have probably done about 6 or 7 version increments back then. I cannot do the same thing anymore of course, it would be silly to release a new version each time I have made a couple of trivial changes.

The changes I have made in the latest version of the compiler are steps towards a working code generator. I am giving priority to the front end things that are needed by the compiler back end. The first such thing in the release of today is checking for the program entry point. This includes checking a 'begin' specification if it is present, finding the 'static procedure main' and doing the necessary checks on it. Another improvement is a basic support for constant folding, except that no folding is done at the moment, but the compiler can already use unsigned integer literals in type checking. This feature is used by another one: checking of array sizes. You can declare arrays with fixed size and the compiler will check their compatibility. And the third important change is passing of parameters that are not to be changed, i.e. 'in' parameters. They are now passed by reference and completely read-only.

The next things on my 'to do'-list are real constant folding and constructor initializer lists. I suppose those are sufficient to allow me to start working on the code generator. I still have compilation problems with the LLVM tools as I wrote in my previous blog post. I don't think this will be a problem because the compiler front end linked with LLVM works perfectly. I can still compile the official version of LLVM and use its tools on the LLVM bytecode generated by my compiler.

Another thing: I don't really get any feedback of users yet. So if you try the compiler, please let me know what you think! Tell me the things you like, not just what you don't like. I have installed a visitor counter on my website some time ago, and it seems that I do have some visitors looking around. Yay! :-)

Wednesday, February 07, 2007

type deduction for variables + back end progress

I have an idea for a new feature for variables: automatic type deduction. A new reserved keyword "auto" is used in place of the type for the variable, and the compiler will deduce the type from the type of the initializer expression. The type will always be a pointer or a reference, to avoid unneeded copies of the initializer.
procedure test(x : int, y : const int, z : * int)
var a : auto = x # var a: & int = x
var b : auto = y # var b : & const int = y
var c : auto = z # var c : * int = z
var d : auto = a + b # var d : & int = a + b
end
I am still working on the compiler back end. Progress is very slow, because I don't have much time to work on it. I got most of the LLVM libraries compiled with CMake (LLVM normally uses GNU autotools), and linked with my front end. The front end currently emits a simple hello world program as LLVM assembly code (regardless of what sourcefile you 'compile'). I did not get the LLVM tools compiled yet; for "llc" I am stuck on a link error about some symbols from libtool. I have never used libtool myself so I don't know how it's used in a program. I will have to take another look and if I can't solve it I will have to ask for some help on the CMake mailing list. I wonder why my compiler gets linked with LLVM without errors and why "llc" fails. Other work in this matter is on the front end. There is some functionality that is needed for code generation that is still missing in the front end. For example, I still need to finish constant folding, because this is required for determining the size of array types. After that I can start implementing real code generation.