Remove mutability from QueryCompiler state (except for the SymbolNamer)

Logging of the source tree is also improved to use the SymbolNamer.