It’s available on the master branch and in nightly builds.
Please be sure to run ecompile in comparison mode, as described in core-changes, in order to ensure that the new compiler doesn’t change the behavior of any of your scripts.
The original compiler is still available. I’ll delete it only after both compilers have been available in an official release for at least several months.
I also wanted to mention some of the reasons why I rewrote the compiler:
- I began work on the original compiler when I was 20 years old! It’s an embarrassing mess. It’s hard to work with. I imagine it’s nearly impossible for anyone but me to understand. It’s difficult to add anything new or change anything. The new compiler is composed of manageable pieces and is a lot easier to understand.
- As a project, the new compiler was safe because it is testable. In the time that I haven’t been working on POL, the good people maintaining it have extended the test suite. That decreases risk. I’ve been away from the codebase for a long time, so this was a nice way to start to re-familiarize myself with it.
- Because the new compiler produces output that is identical* to that of the original compiler, it's easy to know that it didn't break any scripts. This has been tested against the test suite, ModernDistro, and ClassicDistro.
- *with a few exceptions, like changed operator precedence, but ecompile’s “comparison mode” will find any scripts that changed. Notably, the operator precedence changes did not change the .ecl output of any script in ModernDistro or ClassicDistro. The changes to operator precedence are intended to make it so more expressions do what you want without parentheses, rather than having to add them.
- It’s a lot easier to see what is in the instructions that the compiler emits for the executor, because the compiler creates each instruction right before emitting it.
- We can improve eScript and the compiler much more easily. For example:
- add a ternary operator
- add an “is” operator as an alternative to TypeOfInt
- warn about expressions that are likely to be in error
- better expression optimizations
- optimize the instruction set (generally by reducing the number of instructions required to do some common things)
- add short-circuit logical operators
- this was possible with the original compiler, but tricky. I did it with the “Elvis” operator, which is similar to short-circuit OR, but it had to be done in the optimizer. Compare:
- PR-137 adding the Elvis operator to the original compiler (relevant code)
- PR-293 adding the Elvis operator to the new compiler
- this was possible with the original compiler, but tricky. I did it with the “Elvis” operator, which is similar to short-circuit OR, but it had to be done in the optimizer. Compare:
- The new compiler shares far fewer datatypes with the executor, so we’ll be able to simplify some of the executor’s datatypes after deleting the old compiler.