xp-lang/compiler — pull request #34 by thekid (2013-06-02 11:10:12+00:00)
Title: JIT ("Just in time") compilation [file-system]

This pull request implements xp-framework/rfc#271 adds a specialized class loader for the efficient "edit / save / run" paradigm at development time. This is an alternative implementation to pull request #33 which saves compiled files to the disk.

```sh
$ cat > HelloWorld.xp
public class HelloWorld {
public static void main(string[] $args) {
util.cmd.Console::writeLine('Hello ', $args.length ? $args[0] : 'World');
}
}

$ xp HelloWorld
Hello World
```

This will check for the existance of a file called `HelloWorld.class.php`, and if it cannot be found or if it's older than the source file, the compiler will be invoked and save its output to that file. The class will then be defined and loaded, and finally executed.

### File system
The JIT Class loader uses all of the following directories for source files: `src/main/xp`, `src/test/xp`, and the current directory. The output directory is determined by checking for the existance of a `target` subdirectory, or a `dist` directory, and falls back to using the current directory.

### Inner workings
The `xp.compiler.JitClassLoader` gets registered by the file `module.php`, which hooks itself into the bootstrapping process. A bit tricky, have a look...